Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JavaScript Project System (esproj files) #613

Open
hicksjacobp opened this issue Feb 12, 2024 · 0 comments
Open

Support JavaScript Project System (esproj files) #613

hicksjacobp opened this issue Feb 12, 2024 · 0 comments

Comments

@hicksjacobp
Copy link

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:

Possible Solutions

One, or a combination, of the following:

  1. Look for esproj files in FindProjectFile

    A file extension by itself is not truly indicative of a dependency on node/npm, but fairly likely.

  2. Look for usage of the Microsoft.VisualStudio.JavaScript.Sdk SDK in any project file?

    Usage of the SDK would be a better indicator of needing the node/npm commands.

  3. Look for package.json files, similar to how the npm-install build 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:

<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>
. In the case of the ASP.NET React template, this would mean adding customizations to the server csproj file, in order for the client esproj to be built feasibly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant