-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
InvalidProjectFileException when opening a Project using XmlReader #7035
Comments
Team Triage: Does this still reproduce if you use msbuildlocator? |
Using Microsoft.Build.Locator 1.4.1, the console app csproj has changed to
Program.cs
Now whether the console app's Microsoft.Build package references are v16.11.0 or 17.0.0, Project.FromXmlReader(xr, options) throws
|
Thanks for reporting this. I've identified the issue. The NuGet SDK resolver throws an exception when an in-memory project is evaluated. This used to be logged as a warning and evaluation would continue. But now this exception fails evaluation because this change: #6763 The only workaround at the moment is to save the project to disk somewhere so the |
Project.FromXmlReader(...) is still borked when the csproj file is on either a mock disk or real disk. console app csproj
Program.cs
This throws the same exception as before, even if I replace the MockFileSystem with FileSystem
|
Closing in favor of NuGet/Home#11376 |
@benvillalobos I think we should still have an open issue to get a unit test created that would have caught this break. It would have been nice to know it was breaking before 17.0 shipped so that NuGet wasn't caught off guard. |
Issue Description
I use the Microsoft.Build and Microsoft.Build.Utilities.Core Nuget packages to open and inspect csproj files. Using v16.11.0 of these 2 packages, I can open csproj files successfully but v17.0.0 throws InvalidProjectFileException.
Steps to Reproduce
Console application project that opens an in-memory csproj.
Console application's Program.cs
Expected Behavior
The console application should print
Actual Behavior
If the console application references Microsoft.Build 16.11.0 and Microsoft.Build.Utilities.Core 16.11.0 then the console output correctly shows "Project opened successfully".
If the console application references Microsoft.Build 17.0.0 and Microsoft.Build.Utilities.Core 17.0.0 then an InvalidProjectFileException is thrown when calling Project.FromXmlReader(xr, options).
Analysis
If environment variable MSBUILD_EXE_PATH is not set the both 16.11.0 and 17.0.0 throw
If MSBUILD_EXE_PATH is set then 16.11.0 opens successfully, 17.0.0 throws
Using 17.0.0, if only MSBuildExtensionsPath is set then
My console application project is D:\dev\MsBuildTesting\MsBuildTesting.csproj. Using 17.0.0, if only MSBuildSDKsPath is set then
Using 17.0.0, if both MSBuildSDKsPath and MSBuildExtensionsPath are set then
Versions & Configurations
I have both Visual Studio 2019 16.11.6 and Visual Studio 2022 17.0.0 installed.
I am running on Windows 10 Enterprise. Output from ver
Output from dotnet --list-sdks
Output from msbuild -version
The text was updated successfully, but these errors were encountered: