WebCompiler icon indicating copy to clipboard operation
WebCompiler copied to clipboard

Build fails during fingerprinting with .Net 9 SDK

Open kaleidocore opened this issue 1 year ago • 11 comments

Installed product versions

  • Visual Studio: 2022 17.12.0
  • This extension: 1.14.10

Description

(Re)build fails during fingerprinting with the new .Net 9 SDK.

Computing fingerprint and integrity for asset 'wwwroot\tlab.css'
 C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : System.InvalidOperationException: No file exists for the asset at either location 'wwwroot\tlab.css' or 'wwwroot\tlab.css'.
 C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error :    at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.ComputeFingerprintAndIntegrity(String identity, String originalItemSpec)
C:\Program Files\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error :    at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets.Execute()
Done executing task "DefineStaticWebAssets" -- FAILED.

This is the same issue as reported for TypeScript here: https://github.com/dotnet/aspnetcore/issues/58948 The same solution/workaround should work for WebCompiler too, I suspect. Note that a second issue was opened specifically for the TS team here: https://github.com/microsoft/TypeScript/issues/60538 and should probably be our guideline for WebCompiler too.

This problem has actually existed for a long time but would previously fail silently, i.e. the produced .css would sometimes be missing from the Publish output, but the new .Net 9 SDK Fingerprinting feature fails completely with errors.

Steps to recreate

Install VS 17.12.0 (or standalone .Net 9 SDK) Rebuild a project with .scss -> .css compilation using the WebCompiler 2022 Plus nuget. Note that Clean+Build generally succeeds, but Rebuild fails. Please see the linked Github issue for more info.

Current behavior

Rebuild fails because WebCompiler generates its output too late in the build chain.

Expected behavior

Rebuild should succeeed. CSS output should be generated early enough in the build chain for fingerprinting and reliable publishing.

kaleidocore avatar Nov 20 '24 07:11 kaleidocore

@failwyn I really would like to contribute to this, but I don't get the build running locally. NPM and Python is installed. The gyp module can't find my VS 17.12 installation

npm error gyp ERR! stack Error: Could not find any Visual Studio installation to use

twenzel avatar Jan 19 '25 16:01 twenzel

@twenzel That error is from Node SASS, I'll push my latest code with that removed first thing tomorrow morning and you can branch off that.

failwyn avatar Jan 19 '25 17:01 failwyn

@failwyn Did you already pushed the changes?

twenzel avatar Jan 21 '25 13:01 twenzel

@twenzel Sorry about that, I just pushed the changes, work got a bit hectic yesterday and it completely slipped my mind, thanks for the reminder.

failwyn avatar Jan 21 '25 13:01 failwyn

I tried version 1.14.12 but the issue persists. It works fine when building just the single project but when I rebuild the entire solution, and projects depend on it then it gives the error message

Mykullski avatar Feb 18 '25 04:02 Mykullski

@Mykullski I didn't address the issue yet, just the one that was preventing you from being able to build WebCompiler; I'm doing some home repairs, so my free time has been very limited this year.

failwyn avatar Feb 18 '25 12:02 failwyn

@failwyn, the VSIX extension works fine on 1.14.12. The NuGet Package does not work. I tried the NuGet Package with the extension installed and not installed and resulted in the same error when rebuilding the entire solution.

C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : System.InvalidOperationException: No file exists for the asset at either location 'wwwroot\css\theme.css' or 'wwwroot\css\theme.css'. C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.ComputeFingerprintAndIntegrity(String identity, String originalItemSpec) C:\Program Files\dotnet\sdk\9.0.200\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(662,5): error : at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets.Execute()

Mykullski avatar Feb 18 '25 15:02 Mykullski

@Mykullski Until it's published to nuget, you have to add the dlls manually from your build for testing.

failwyn avatar Feb 18 '25 23:02 failwyn

@failwyn, when I tested it, I tested it by

  1. Cloning the repo
  2. Making a NuGet package
  3. Add it to a local feed
  4. Upgraded to the new version 1.14.12

The issue is still there.

Mykullski avatar Feb 19 '25 01:02 Mykullski

@Mykullski I'll try to take a look at it when I finish with the house repairs, if you want to try fixing it, I'd be happy to review your pull request.

failwyn avatar Feb 19 '25 11:02 failwyn

Add the following to your project file to fix this until a proper fix is found.

<PropertyGroup> <PrepareForBuildDependsOn> WebCompile;$(PrepareForBuildDependsOn) </PrepareForBuildDependsOn> </PropertyGroup>

Build => Clean Solution Build => Rebuild Solution

https://github.com/dotnet/aspnetcore/issues/58948

failwyn avatar Mar 24 '25 17:03 failwyn