You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The presence of .NET SDK v 7.0.201 causes my application to fail to instantiate/load a Microsoft.Build.Evaluation.Project. If the .NET SDK v7.0.201 is removed so that only v7.0.100 and earlier exist, the project loads fine.
To Reproduce
To reproduce this
Make sure that v7.0.201 is installed and no newer versions are installed (so that it is the Last).
Create a new .NET 6 console application
Add the following code, changing the csproj path assigned to fileName with a path to a valid .NET 6 project
using Microsoft.Build.Evaluation;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace ProjLoadingTest;
internal class Program
{
static void Main(string[] args)
{
var startInfo = new ProcessStartInfo("dotnet", "--list-sdks")
{
RedirectStandardOutput = true
};
var process = Process.Start(startInfo);
process.WaitForExit(1000);
var output = process.StandardOutput.ReadToEnd();
var sdkPaths = Regex.Matches(output, "([0-9]+.[0-9]+.[0-9]+) \\[(.*)\\]")
.OfType<Match>()
.Select(m => System.IO.Path.Combine(m.Groups[2].Value, m.Groups[1].Value, "MSBuild.dll"))
.ToArray();
if (sdkPaths.Count() > 0)
{
var sdkPath = sdkPaths.Last();
Environment.SetEnvironmentVariable("MSBUILD_EXE_PATH", sdkPath);
}
var fileName = @"C:\Users\vchel\Documents\GitHub\BattleCryptBombers\BattleCryptBombers\BattleCryptBombers.csproj";
var myProject = new Project(fileName);
}
}
Run the code
Observe - the exception is thrown as shown below
Expected - no exception is thrown, and the Project is loaded the same as when only v7.0.100 is installed, or when only .NET 6 SDK is installed.
Exceptions (if any)
SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "Microsoft.NET.Sdk". Exception: "System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult)"" C:\Users\vchel\Documents\GitHub\BattleCryptBombers\BattleCryptBombers\BattleCryptBombers
The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
I can reproduce this when I run the code from Visual Studio 2022 17.4.2 if I have the .NET SDK 7.0.201 installed.
I cannot reproduce this if the SDK is uninstalled. If Visual Studio 2022 17.5.1 is installed, then this also installs the SDK v7.0.201 so this bug will always reproduce.
The text was updated successfully, but these errors were encountered:
Describe the bug
The presence of .NET SDK v 7.0.201 causes my application to fail to instantiate/load a
Microsoft.Build.Evaluation.Project
. If the .NET SDK v7.0.201 is removed so that only v7.0.100 and earlier exist, the project loads fine.To Reproduce
To reproduce this
fileName
with a path to a valid .NET 6 projectObserve - the exception is thrown as shown below
Expected - no exception is thrown, and the Project is loaded the same as when only v7.0.100 is installed, or when only .NET 6 SDK is installed.
Exceptions (if any)
Further technical details
dotnet --info
With Version 7.0.201 installed the crash occurs:
Without Version 7.0.201 installed everything works correctly:
I can reproduce this when I run the code from Visual Studio 2022 17.4.2 if I have the .NET SDK 7.0.201 installed.
I cannot reproduce this if the SDK is uninstalled. If Visual Studio 2022 17.5.1 is installed, then this also installs the SDK v7.0.201 so this bug will always reproduce.
The text was updated successfully, but these errors were encountered: