Build fails during fingerprinting with .Net 9 SDK
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.
@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 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 Did you already pushed the changes?
@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.
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 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, 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 Until it's published to nuget, you have to add the dlls manually from your build for testing.
@failwyn, when I tested it, I tested it by
- Cloning the repo
- Making a NuGet package
- Add it to a local feed
- Upgraded to the new version 1.14.12
The issue is still there.
@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.
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