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

MSBuild.SDK.SystemWeb/4.0.82 projects do not load in Visual Studio 2022 17.5.0 #52

Closed
stevenvolckaert opened this issue Feb 23, 2023 · 10 comments

Comments

@stevenvolckaert
Copy link

I just upgraded my Visual Studio Professional 2022 instance to version 17.5.0, which was released on 21 February 2023.

My MSBuild.SDK.SystemWeb/4.0.82 projects do not load any more:

image

The log file shows:

===================
2023-02-23 09:17:20
LimitedFunctionality
Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'CommandLineArgsForDesignTimeEvaluation' is required.
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.EvaluationData.GetRequiredPropertyValue(String name)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProjectFactory.<CreateProjectContextAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
===================
2023-02-23 09:17:20
LimitedFunctionality
Microsoft.VisualStudio.LanguageServices.ProjectSystem.InvalidProjectDataException: Property 'CommandLineArgsForDesignTimeEvaluation' is required.
   at Microsoft.VisualStudio.LanguageServices.ProjectSystem.EvaluationData.GetRequiredPropertyValue(String name)
   at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS.CPSProjectFactory.<CreateProjectContextAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.LanguageServices.Workspace.<>c__DisplayClass39_0.<<OnEvaluationUpdateAsync>g__ProcessInitialEvaluationDataAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__Action|0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
===================

I could workaround this by adding property CommandLineArgsForDesignTimeEvaluation to my .csproj files (source):

<PropertyGroup>
  <CommandLineArgsForDesignTimeEvaluation>-langversion:$(LangVersion)</CommandLineArgsForDesignTimeEvaluation>
  <CommandLineArgsForDesignTimeEvaluation Condition="'$(DefineConstants)' != ''">$(CommandLineArgsForDesignTimeEvaluation) -define:$(DefineConstants)</CommandLineArgsForDesignTimeEvaluation>
</PropertyGroup>
@jantje85
Copy link

I have the same problem.
The workaround suggested by @stevenvolckaert works

@CZEMacLeod
Copy link
Owner

Looks like they never fixed 17.5. dotnet/roslyn#66367 (comment)

Either switch your install to 17.4.4 LTSC or use the 17.6.0P1.0 Preview editions...

I haven't had time to evaluate the suggested fix above but that may also work - if those lines are in the common,msbuild includes, I'm not sure why they aren't pulled in already...

@stevenvolckaert
Copy link
Author

Thank you for your suggestion @CZEMacLeod!

Adding property CommandLineArgsForDesignTimeEvaluation to the .csproj files works for now, though. When 17.6.0 is available I'll remove it and report back here.

@drewnoakes
Copy link

When 17.6.0 is available I'll remove it and report back here.

Hopefully with dotnet/roslyn#67000 this will be fixed in 17.5.1.

@leusbj
Copy link
Contributor

leusbj commented Feb 28, 2023

This is just as an FYI, because I don't have an offending version of Visual Studio installed to confirm.

It appears that the CommandLineArgsForDesignTimeEvaluation property is being set in the Microsoft.CSharp.Core.targets file delivered as part of Roslyn. The particular flavor that's actually used during build time is dependent on project config and how build is triggered

  • Version from Microsoft.Net.Compilers.Toolset (version 4.4.0 and greater) - Whenever project being built includes reference to this package
  • Version from MSBuild as part of Visual Studio - When Visual Studio Build is triggered (and project does not reference to the Microsoft.Net.Compilers.Toolset package)
  • Version from dotnet Sdk - Built without Visual Studio from dotnet command (and project does not reference to the Microsoft.Net.Compilers.Toolset package)

This Sdk by default will include a reference to the Microsoft.Net.Compilers.Toolset package (currently 4.3.0). So one more potential work around until projectsystem does not "Require" this property could be:

If you are currently allowing this Sdk to include the default packages (you HAVE NOT overriden the default behavior by setting <ExcludeASPNetCompilers>true</ExcludeASPNetCompilers>), then you could set this Sdk's MicrosoftNetCompilersToolset_Version property to 4.4.0 instead of this Sdk's current default of 4.3.0 with something like:

  <PropertyGroup>
    <MicrosoftNetCompilersToolset_Version>4.4.0</MicrosoftNetCompilersToolset_Version>
  </PropertyGroup>

Alternatively if you are currently not allowing this Sdk to include the default packages (you HAVE overriden the default behavior with <ExcludeASPNetCompilers>true</ExcludeASPNetCompilers>), then you can manually add a PackageReference to one of the later Microsoft.Net.Compilers.Toolset packages with something like:

  <ItemGroup>
    <PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.4.0" PrivateAssets="All" />
  </ItemGroup>

@ChristophWeigert
Copy link

Seems like they fixed it with 17.5.1

@stevenvolckaert
Copy link
Author

I confirm; updating to Visual Studio 17.5.1 fixes this issue.

See Visual Studio 17.5.1 release notes for more information.

@CZEMacLeod
Copy link
Owner

@leusbj I think the next release of the SDK should bump Microsoft.Net.Compilers.Toolset to 4.4.0 by default to ensure this doesn't break on e.g. build servers etc.

@leusbj
Copy link
Contributor

leusbj commented Mar 1, 2023

@leusbj I think the next release of the SDK should bump Microsoft.Net.Compilers.Toolset to 4.4.0 by default to ensure this doesn't break on e.g. build servers etc.

@CZEMacLeod Would like this change to the 'MicrosoftNetCompilersToolset_Version' incorporated with the pending changes to support CPM? Or since the CPM isn't as straight forward, do this change as a standalone change, and back that change into the PR for the CPM Stuff?

@CZEMacLeod
Copy link
Owner

@leusbj V4.0.88 includes the new version (V4.5.0 in fact). I felt that getting a couple of small changes in to fix some of the outstanding issues was a good bet, then we can do the CPM work as a separate task.

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

6 participants