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

[wasm] wasmconsole template: Add <WasmExtraFilesToDeploy> to Up-to-date Check #77285

Open
JakeYallop opened this issue Oct 20, 2022 · 13 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-Build-mono
Milestone

Comments

@JakeYallop
Copy link
Contributor

Consider I have the following in my wasm browser project:

  <ItemGroup>
    <WasmExtraFilesToDeploy Include="main.js" />
  </ItemGroup>

I make some changes to some C# code, and perform a build. I then get the following output in Visual Studio:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I then realise that some of my JavaScript isn't quite right in main.js so and go and update it - I then do another build, only to see

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

The new version of main.js has not been copied over to the AppBundle directory. The only way around this is to do a full rebuild, or a clean and a rebuild. Its is an awkward change a workflow that usually involves just making a change, and then pressing Ctrl + Shift + B to perform a rebuild.

This is due to the FastUpToDate check performed by Visual Studio - the system is documented here: https://github.com/dotnet/project-system/blob/main/docs/up-to-date-check.md

Initially I tried the following, documented solution (just focusing on main.js for the moment):

    <!-- MyWasmProject.csproj -->
    <ItemGroup>
      <UpToDateCheckBuilt Include="$(WasmAppDir)/main.js" Original="$(MSBuildThisFileDirectory)main.js" />
    </ItemGroup>

Unfortunately, this does not work, as $(WasmAppDir) is not defined until a build has actually been started:

<Target Name="_BeforeWasmBuildApp" DependsOnTargets="$(_BeforeWasmBuildAppDependsOn)">
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')" Text="MicrosoftNetCoreAppRuntimePackRidDir=$(MicrosoftNetCoreAppRuntimePackRidDir) doesn't exist" />
<Error Condition="@(WasmAssembliesToBundle->Count()) == 0" Text="WasmAssembliesToBundle item is empty. No assemblies to process" />
<PropertyGroup>
<WasmAppDir Condition="'$(WasmAppDir)' == ''">$([MSBuild]::NormalizeDirectory($(OutputPath), 'AppBundle'))</WasmAppDir>
<WasmMainAssemblyFileName Condition="'$(WasmMainAssemblyFileName)' == ''">$(TargetFileName)</WasmMainAssemblyFileName>
<WasmAppDir>$([MSBuild]::NormalizeDirectory($(WasmAppDir)))</WasmAppDir>
<_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll' and $(WasmGenerateAppBundle) == 'true'">%(WasmAssembliesToBundle.Identity)</_MainAssemblyPath>
<_WasmRuntimeConfigFilePath Condition="'$(_WasmRuntimeConfigFilePath)' == '' and $(_MainAssemblyPath) != ''">$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json'))</_WasmRuntimeConfigFilePath>
<_ParsedRuntimeConfigFilePath Condition="'$(_WasmRuntimeConfigFilePath)' != ''">$([System.IO.Path]::GetDirectoryName($(_WasmRuntimeConfigFilePath)))\runtimeconfig.bin</_ParsedRuntimeConfigFilePath>
</PropertyGroup>

Is there a specific reason that the variable is defined this way? Is there a different way that the UpToDateCheckBuilt can be registered so the target registers the changes to main.js (and other WasmExtraFilesToDeploy)?

I'd be happy to contribute a PR - at the very least I'd like to move the declaration of $(WasmAppDir) outside the of target if possible, so that I can define my own conditions that use it.

Workarounds

  • Hardcode the $(WasmAppDir) inside UpToDateCheckBuilt - this makes any code a little fragile.
  • Explicitly set a $(WasmAppDir) - again, not ideal.
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 20, 2022
@radical radical added the arch-wasm WebAssembly architecture label Oct 21, 2022
@ghost
Copy link

ghost commented Oct 21, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Consider I have the following in my wasm browser project:

  <ItemGroup>
    <WasmExtraFilesToDeploy Include="main.js" />
  </ItemGroup>

I make some changes to some C# code, and perform a build. I then get the following output in Visual Studio:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I then realise that some of my JavaScript isn't quite right in main.js so and go and update it - I then do another build, only to see

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

The new version of main.js has not been copied over to the AppBundle directory. The only way around this is to do a full rebuild, or a clean and a rebuild. Its is an awkward change a workflow that usually involves just making a change, and then pressing Ctrl + Shift + B to perform a rebuild.

This is due to the FastUpToDate check performed by Visual Studio - the system is documented here: https://github.com/dotnet/project-system/blob/main/docs/up-to-date-check.md

Initially I tried the following, documented solution (just focusing on main.js for the moment):

    <!-- MyWasmProject.csproj -->
    <ItemGroup>
      <UpToDateCheckBuilt Include="$(WasmAppDir)/main.js" Original="$(MSBuildThisFileDirectory)main.js" />
    </ItemGroup>

Unfortunately, this does not work, as $(WasmAppDir) is not defined until a build has actually been started:

<Target Name="_BeforeWasmBuildApp" DependsOnTargets="$(_BeforeWasmBuildAppDependsOn)">
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')" Text="MicrosoftNetCoreAppRuntimePackRidDir=$(MicrosoftNetCoreAppRuntimePackRidDir) doesn't exist" />
<Error Condition="@(WasmAssembliesToBundle->Count()) == 0" Text="WasmAssembliesToBundle item is empty. No assemblies to process" />
<PropertyGroup>
<WasmAppDir Condition="'$(WasmAppDir)' == ''">$([MSBuild]::NormalizeDirectory($(OutputPath), 'AppBundle'))</WasmAppDir>
<WasmMainAssemblyFileName Condition="'$(WasmMainAssemblyFileName)' == ''">$(TargetFileName)</WasmMainAssemblyFileName>
<WasmAppDir>$([MSBuild]::NormalizeDirectory($(WasmAppDir)))</WasmAppDir>
<_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll' and $(WasmGenerateAppBundle) == 'true'">%(WasmAssembliesToBundle.Identity)</_MainAssemblyPath>
<_WasmRuntimeConfigFilePath Condition="'$(_WasmRuntimeConfigFilePath)' == '' and $(_MainAssemblyPath) != ''">$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json'))</_WasmRuntimeConfigFilePath>
<_ParsedRuntimeConfigFilePath Condition="'$(_WasmRuntimeConfigFilePath)' != ''">$([System.IO.Path]::GetDirectoryName($(_WasmRuntimeConfigFilePath)))\runtimeconfig.bin</_ParsedRuntimeConfigFilePath>
</PropertyGroup>

Is there a specific reason that the variable is defined this way? Is there a different way that the UpToDateCheckBuilt can be registered so the target registers the changes to main.js (and other WasmExtraFilesToDeploy)?

I'd be happy to contribute a PR - at the very least I'd like to move the declaration of $(WasmAppDir) outside the of target if possible, so that I can define my own conditions that use it.

Workarounds

  • Hardcode the $(WasmAppDir) inside UpToDateCheckBuilt - this makes any code a little fragile.
  • Explicitly set a $(WasmAppDir) - again, not ideal.
Author: JakeYallop
Assignees: -
Labels:

arch-wasm, untriaged

Milestone: -

@radical radical added this to the 8.0.0 milestone Oct 21, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Oct 21, 2022
@radical
Copy link
Member

radical commented Oct 21, 2022

I think one of the reasons for having it in a target was that OutputPath wasn't set at project evaluation time in some cases.

  • When you add a file to @(UpToDateCheckInput), then what "output" does it get compared against? Would it work to have <UpToDateCheckInput Include="@(WasmExtraFilesToDeploy)" /> ?
  • What if we do <UpToDateCheckBuilt Include="@(WasmExtraFilesToDeploy -> '%(RelativeDir)')" \>, then will that be checking with $(OutputPath)?
  • If nothing else, CollectUpToDate* target could be used.

@JakeYallop
Copy link
Contributor Author

When you add a file to @(UpToDateCheckInput), then what "output" does it get compared against?

Its not clear to me either what this would compare to. I've done some testing using different UpToDateCheck* elements, the output is which is below.

Reference output for a correct up to date check
For reference, this is what we should get (I produced this by hardcoding the path to main.js):

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding newest import input: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding Compile inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\Program.cs (MyWasmProject)
1>FastUpToDate: No inputs are newer than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 19:59:43.100). Newest input is 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' (2022-10-21 18:42:32.612). (MyWasmProject)
1>FastUpToDate: Checking copied output (UpToDateCheckBuilt with Original property) file: (MyWasmProject)
1>FastUpToDate:     Source 2022-10-21 08:48:38.034: 'C:\Workspaces\MyWasmProject\MyWasmProject\main.js' (MyWasmProject)
1>FastUpToDate:     Destination 2022-10-21 08:48:38.034: 'C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\main.js' (MyWasmProject)
1>FastUpToDate: Project is up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

I did the following steps for each UpToDateCheck* element:

  1. Update the csproj with <UpToDateCheck* Include="@(WasmExtraFilesToDeploy)" />
  2. Build twice (to handle the update to the csproj)
  3. Make a change to main.js
  4. Build again (for the update to main.js)
  5. Build once more (should get 1 up-to-date, as main.js has been built once already)

I get the following output:

<UpToDateCheckBuilt Include="@(WasmExtraFilesToDeploy)"/>

First build after a change to main.js

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\main.js (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\index.html (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:01:54.301) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:01:54.301) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. See https://aka.ms/incremental-build-failure.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Output from next build (should be up to date at this point)

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\main.js (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\index.html (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:01:54.301) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:01:54.301) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. See https://aka.ms/incremental-build-failure.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

<UpToDateCheckOutput Include="@(WasmExtraFilesToDeploy)" />

First build after a change to main.js

Build started...
1>FastUpToDate: Adding UpToDateCheckOutput outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\main.js (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\index.html (MyWasmProject)
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:05:45.395) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:05:45.395) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. See https://aka.ms/incremental-build-failure.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Output from next build (should be up to date at this point)

Build started...
1>FastUpToDate: Adding UpToDateCheckOutput outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\main.js (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\index.html (MyWasmProject)
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:05:45.395) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 20:05:45.395) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html' (2022-10-21 08:27:10.738), not up-to-date. See https://aka.ms/incremental-build-failure.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

<UpToDateCheckInput Include="@(WasmExtraFilesToDeploy)" />

First build after a change to main.js

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding newest import input: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding Compile inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\Program.cs (MyWasmProject)
1>FastUpToDate: Adding UpToDateCheckInput inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\main.js (MyWasmProject)
1>FastUpToDate: Input UpToDateCheckInput item 'C:\Workspaces\MyWasmProject\MyWasmProject\main.js' is newer (2022-10-21 20:07:22.423) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 20:07:17.516), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:00.334 ==========
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Input UpToDateCheckInput item 'C:\Workspaces\MyWasmProject\MyWasmProject\main.js' is newer (2022-10-21 20:07:22.423) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 20:07:17.516), not up-to-date. See https://aka.ms/incremental-build-failure.

Output from next build (should be up to date at this point)

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding newest import input: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding Compile inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\Program.cs (MyWasmProject)
1>FastUpToDate: Adding UpToDateCheckInput inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\main.js (MyWasmProject)
1>FastUpToDate: Input UpToDateCheckInput item 'C:\Workspaces\MyWasmProject\MyWasmProject\main.js' is newer (2022-10-21 20:07:22.423) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 20:07:17.516), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:00.338 ==========
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Input UpToDateCheckInput item 'C:\Workspaces\MyWasmProject\MyWasmProject\main.js' is newer (2022-10-21 20:07:22.423) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 20:07:17.516), not up-to-date. See https://aka.ms/incremental-build-failure.

<UpToDateCheckBuilt Include="@(WasmExtraFilesToDeploy -> '%(RelativeDir)')" />

First build after a change to main.js (looks like it hasn't detected a change at all)

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding newest import input: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding Compile inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\Program.cs (MyWasmProject)
1>FastUpToDate: No inputs are newer than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 20:09:09.410). Newest input is 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' (2022-10-21 20:09:08.503). (MyWasmProject)
1>FastUpToDate: Project is up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

Output from next build (should be up to date at this point) - same output as above

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding newest import input: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Adding Compile inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\Program.cs (MyWasmProject)
1>FastUpToDate: No inputs are newer than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 20:09:09.410). Newest input is 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' (2022-10-21 20:09:08.503). (MyWasmProject)
1>FastUpToDate: Project is up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.5 ms (MyWasmProject)
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

Any of these options appear to break the up to date check - no subsequent build sees that the files are up to date.

@radical
Copy link
Member

radical commented Oct 21, 2022

IIUC, the output assembly, pdbs, app.config etc are the output files compared against. We can add a target to run before CollectUpToDateCheckBuiltDesignTime target, and add all the relevant paths to @(UpToDateCheckBuilt) specifying the source, and the destination paths.
And I think we could even utilize https://github.com/dotnet/project-system/blob/main/docs/up-to-date-check.md#grouping-inputs-and-outputs-into-sets .

@JakeYallop
Copy link
Contributor Author

I've been testing this a bit more (still a hardcoded wasm app dir):

	<ItemGroup>
		<WasmExtraFilesToDeploy Include="index.html" />
		<WasmExtraFilesToDeploy Include="main.js" />
	</ItemGroup>

	<Target Name="CollectWasmExtraFilesToDeploy" BeforeTargets="CollectUpToDateCheckBuiltDesignTime">
		<ItemGroup>
			<UpToDateCheckBuilt Include="@(WasmExtraFilesToDeploy -> '$(OutputPath)/AppBundle/%(Filename)%(Extension)')" Original="@(WasmExtraFilesToDeploy -> '$(MSBuildThisFileDirectory)%(Filename)%(Extension)')" />
		</ItemGroup>
		<Message Text="WasmAppDir is $(WasmAppDir)" />
		<Error Text="WasmAppDir is $(WasmAppDir)" />
	</Target>

I can't get the <Message> target to display anything, which is why the error is there, This outputs the following:

WasmAppDir is

So it still looks like no luck - unless I'm not quite following what you meant above. From what I understand sets seems like a performance optimization, so I figured we should ignore them for now until we get something basic working.

Once the error target is commented out (so the fast up to date check can continue), we get the following output

Build started...
1>FastUpToDate: Adding UpToDateCheckBuilt outputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.dll (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.pdb (MyWasmProject)
1>FastUpToDate: Adding project file inputs: (MyWasmProject)
1>FastUpToDate:     C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj (MyWasmProject)
1>FastUpToDate: Input 'C:\Workspaces\MyWasmProject\MyWasmProject\MyWasmProject.csproj' is newer (2022-10-21 22:07:41.955) than earliest output 'C:\Workspaces\MyWasmProject\MyWasmProject\obj\Debug\net7.0\browser-wasm\MyWasmProject.pdb' (2022-10-21 22:07:23.783), not up-to-date. (MyWasmProject)
1>FastUpToDate: Up-to-date check completed in 0.4 ms (MyWasmProject)
1>------ Build started: Project: MyWasmProject, Configuration: Debug Any CPU ------
1>C:\Program Files\dotnet\sdk\7.0.100-rc.2.22477.23\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(257,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
1>MyWasmProject -> C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\MyWasmProject.dll
1>Generated app bundle at C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\
WARNING: Potential build performance issue in 'MyWasmProject.csproj'. The project does not appear up-to-date after a successful build: Source 'C:\Workspaces\MyWasmProject\MyWasmProject\index.html;C:\Workspaces\MyWasmProject\MyWasmProject\main.js;C:\Workspaces\MyWasmProject\MyWasmProject\index.html;C:\Workspaces\MyWasmProject\MyWasmProject\main.js' does not exist for copy to 'C:\Workspaces\MyWasmProject\MyWasmProject\bin\Debug\net7.0\browser-wasm\AppBundle\index.html', not up-to-date. See https://aka.ms/incremental-build-failure.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

If I only have 1 WasmExtraFilesToDeploy:

	<ItemGroup>
		<WasmExtraFilesToDeploy Include="main.js" />
	</ItemGroup>

	<Target Name="CollectWasmExtraFilesToDeploy" BeforeTargets="CollectUpToDateCheckBuiltDesignTime">
		<ItemGroup>
			<UpToDateCheckBuilt Include="@(WasmExtraFilesToDeploy -> '$(OutputPath)/AppBundle/%(Filename)%(Extension)')" Original="@(WasmExtraFilesToDeploy -> '$(MSBuildThisFileDirectory)%(Filename)%(Extension)')" />
		</ItemGroup>
	</Target>

We actually get a successful up to date check (again, still with a hardcoded AppBundle dir), so I'm not sure if my transform is incorrect in order to work with multiple inputs.

@radical radical changed the title Add <WasmExtraFilesToDeploy> to Up-to-date Check [wasm] wasmbrowser template: Add <WasmExtraFilesToDeploy> to Up-to-date Check Aug 13, 2023
@radical
Copy link
Member

radical commented Aug 13, 2023

Specifying a <ItemType Name="WasmExtraFilesToDeploy" DisplayName="Wasm extra files to deploy" /> would make these get picked up automatically. For that, we need to explore how to extend the project-system to provide the custom .xaml for this (https://github.com/microsoft/VSProjectSystem/blob/master/doc/extensibility/custom_item_types.md).

We should also consider what else should be added to these up-to-date checks for wasm template apps.

@lewing lewing modified the milestones: 8.0.0, 9.0.0 Aug 13, 2023
@maraf
Copy link
Member

maraf commented Aug 24, 2023

The wasmbrowser is migrated to WebAssembly SDK and the underlaying StaticWebAssets handle incrementalism correctly.

@JakeYallop
Copy link
Contributor Author

JakeYallop commented Oct 22, 2023

Just wanted to chime in with an update on this issue - it doesn't appear to be fixed using 8.0.0-rc.2.23479.6.

Given the following

<WasmExtraFilesToDeploy Include="dist/main.js" />

After making a direct change to the file at "dist/main.js", the FUTDC does NOT detect the change, so performing a build just results in

========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

As WASM now uses tooling centralised in the SDK, it would be good to figure out if this is a bug the within the StaticWebAssets tooling from the SDK, or if its a bug with how <WasmExtraFilesToDeploy> integrates with it.

Could this be because I am using the SDK specified in wasmconsole - <Project Sdk="Microsoft.NET.Sdk"> rather than <Project Sdk="Microsoft.NET.Sdk.WebAssembly">?

Edit:
Done some testing with the wasmbrowser template, and changes to the just "wwwroot/main.js" file do not cause a rebuild and are not copied to the build output.

The csproj file for the wasmbrowser template has

<WasmExtraFilesToDeploy Include="./wwwroot/main.js" />

in the csproj.

So, it seems like this is still an issue.

@maraf
Copy link
Member

maraf commented Oct 23, 2023

Could this be because I am using the SDK specified in wasmconsole - <Project Sdk="Microsoft.NET.Sdk"> rather than <Project Sdk="Microsoft.NET.Sdk.WebAssembly">?

Yes. The wasmbrowser was migrated to <Project Sdk="Microsoft.NET.Sdk.WebAssembly"> in RC2. It is the preferred SDK when targeting Web (console will be migrated as well, probably in .NET 9).

The WasmExtraFilesToDeploy is not needed in Microsoft.NET.Sdk.WebAssembly as everyting under wwwroot is considered as web files to deploy. During build, the Microsoft.NET.Sdk.WebAssembly doesn't copy wwwroot to output directory, instead it reads files from the original wwwroot folder in the project. The wwwroot folder is copied only during publish and as this functionaly is common with blazor, I believe it works correctly (definitely let us know if it doesn't).

@JakeYallop JakeYallop changed the title [wasm] wasmbrowser template: Add <WasmExtraFilesToDeploy> to Up-to-date Check [wasm] wasmconsole template: Add <WasmExtraFilesToDeploy> to Up-to-date Check Oct 23, 2023
@JakeYallop
Copy link
Contributor Author

JakeYallop commented Oct 23, 2023

I've just realised that the issue title has wasmbrowser in the title. At the time, this was correct (as there wasn't the distinction between wasmbrowser (minimal WASM blazor app) and wasmconsole (WASM library meant to be used by something else)), however, now that WasmExtraFilesToDeploy is now no-longer needed in wasmbrowser, the issue only affects the wasmconsole template.

I've updated the title to reflect that.

@lewing lewing assigned maraf and unassigned radical Feb 9, 2024
@maraf
Copy link
Member

maraf commented Feb 17, 2024

The plan is to resolve this issue by migrating the template to WebAssembly SDK, tracked in #70762

@ilonatommy
Copy link
Member

Updating: template migration is tracked by #102743

@maraf maraf modified the milestones: 9.0.0, 10.0.0 Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-Build-mono
Projects
None yet
Development

No branches or pull requests

5 participants