-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Describe the Enhancement
This build pack currently only supports discovering csproj, fsproj, and vbproj files (see source). Additionally, this build pack only detects the need for node/npm when it sees either referenced in a Target/Exec/Command XML element hierarchy (see source).
Microsoft / Visual Studio also has esproj files, which are used for JavaScript projects. esproj files also don't use a Target/Exec/Command structure because it's hidden behind the Microsoft.VisualStudio.JavaScript.Sdk SDK, and instead an esproj file looks like:
<Project Sdk="Microsoft.VisualStudio.JavaScript.Sdk/0.5.128-alpha">
<PropertyGroup>
<StartupCommand>npm run dev</StartupCommand>
<JavaScriptTestRoot>src\</JavaScriptTestRoot>
<JavaScriptTestFramework>Jest</JavaScriptTestFramework>
<!-- Allows the build (or compile) script located on package.json to run on Build -->
<ShouldRunBuildScript>false</ShouldRunBuildScript>
<!-- Folder where production build objects will be placed -->
<PublishAssetsDirectory>$(MSBuildProjectDirectory)\dist</PublishAssetsDirectory>
</PropertyGroup>
</Project>For reference of esproj files, please see:
- Property pages for React, Angular, and Vue projects in Visual Studio
- JavaScript and TypeScript in Visual Studio | Project templates
- MSBuild reference for the JavaScript Project System
- Tutorial: Create an ASP.NET Core app with React in Visual Studio
Possible Solutions
One, or a combination, of the following:
-
Look for
esprojfiles in FindProjectFileA file extension by itself is not truly indicative of a dependency on node/npm, but fairly likely.
-
Look for usage of the
Microsoft.VisualStudio.JavaScript.SdkSDK in any project file?Usage of the SDK would be a better indicator of needing the node/npm commands.
-
Look for
package.jsonfiles, similar to how thenpm-installbuild pack detects its need (see source)?This may be a bit of a stretch for this build pack without a direct linkage to some .NET project / solution.
Motivation
With lack of support for esproj files, it requires developers to add unnecessary customizations to other project files in order for node/npm to be detected as being necessary and available during a build, similar to a MSBuild Target like what's in the Angular MSBuild .csproj file:
dotnet-publish/integration/testdata/angular_msbuild/angular_msbuild.csproj
Lines 24 to 32 in 982a8ad
| <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') "> | |
| <!-- Ensure Node.js is installed --> | |
| <Exec Command="node --version" ContinueOnError="true"> | |
| <Output TaskParameter="ExitCode" PropertyName="ErrorCode" /> | |
| </Exec> | |
| <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /> | |
| <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /> | |
| <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> | |
| </Target> |
csproj file, in order for the client esproj to be built feasibly.