dotnet / project-system

The .NET Project System for Visual Studio
MIT License
959 stars 386 forks source link

FastUpToDate: Up-to-date check threw System.ArgumentNullException for wix4 project #9348

Open svg2003 opened 7 months ago

svg2003 commented 7 months ago

Visual Studio Version

Version 17.7.7

Summary

TestWix4Package.zip

For wix4 project, FastUpToDate throws below exception. Looking on place, MsBuildProjectDirectory is null, albeit ProjectTargetPath contains correct value.

This is in MSVS output

Build started...
1>FastUpToDate: Up-to-date check threw an exception. Not up-to-date. System.ArgumentNullException: Value cannot be null.
1>Parameter name: path1
1>   at System.IO.Path.Combine(String path1, String path2)
1>   at Microsoft.VisualStudio.ProjectSystem.UpToDate.BuildUpToDateCheck.<>c__DisplayClass44_0.<<IsUpToDateInternalAsync>g__CheckAsync|0>d.MoveNext() (TestWix4Package)
1>FastUpToDate: Up-to-date check completed in 67.5 ms (TestWix4Package)

https://github.com/dotnet/project-system/blob/main/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UpToDate/BuildUpToDateCheck.cs#L1084

Steps to Reproduce

  1. Create new project from standard template: "MSI Package (Wix v4)"
  2. Try to build that project

Expected Behavior

No exception, and fastuptodate works for wix projects

Actual Behavior

Since fastcheck doesn't work, projects are constantly rebuilds TestWix4Package.zip

User Impact

adamint commented 6 months ago

@drewnoakes assigning you, if that's alright.

jeremy-visionaid commented 6 months ago

I'm seeing this too. Curiously, setting <DisableFastUpToDateCheck>True</DisableFastUpToDateCheck> has no effect either.

drewnoakes commented 3 months ago

As @svg2003 says, the exception's coming from here:

https://github.com/dotnet/project-system/blob/34eb57b35962367b71c2a1d79f6c486945586e24/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UpToDate/BuildUpToDateCheck.cs#L1084

Both implicitState.MSBuildProjectDirectory and implicitState.OutputRelativeOrFullPath are nullable, yet Path.Combine disallows null arguments.

We need to understand why those values might be null for WIX projects (or in general). And in cases where they are null, we need to decide what to do about it. For example, should we just declare the project out-of-date? Or should we just skip certain checks?

The same problem exists higher up in the file, in:

https://github.com/dotnet/project-system/blob/34eb57b35962367b71c2a1d79f6c486945586e24/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/UpToDate/BuildUpToDateCheck.cs#L733