Open CheloXL opened 1 year ago
Tried a quick repro and mscorlib is being provided to the compiler here which is the root of the errors:
Note: I do not know if the SDK intended for this to work or not. I will let them decide but we're definitely getting mscorlib passed here.
Investigated and found this PR 10981 Just disable the newly added AutomaticallyUseReferenceAssemblyPackages option in your csproj to solve the problem:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<NoStdLib>true</NoStdLib>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<AutomaticallyUseReferenceAssemblyPackages>false</AutomaticallyUseReferenceAssemblyPackages>
</PropertyGroup>
</Project>
This allows you to use more recent versions of the .NET Core SDKs to build projects that need the NoStdLib option.
Version Used: .NET SDK: Version: 7.0.100 Commit: e12b7af219
Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.100\
Host: Version: 7.0.0 Architecture: x64 Commit: d099f075e4
.NET SDKs installed: 6.0.201 [C:\Program Files\dotnet\sdk] 6.0.301 [C:\Program Files\dotnet\sdk] 7.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Steps to Reproduce: I have a project that it's a custom mscorlib library. This is the csproj that I'm using to build it:
The code was compiling fine under netcore6. After upgrading to netcore7, I'm getting hundred of errors, like
...\Attributes\Reflection\AssemblyTitleAttribute.cs(4,47): warning CS0436: The type 'Attribute' in '...\System\Attribute.cs' conflicts with the imported type 'Attribute' in 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Using the type defined in '...\System\Attribute.cs'. [...\jscorelib.csproj]
or also...\System\Byte.cs(9,35): error CS0556: User-defined conversion must convert to or from the enclosing type [...\jscorelib.csproj]
Comparing the old project.assets.json generated under obj with the new one, I see that now the compiler is importing the built-in references assemblies.Old assets (working... I trimmed some entries not relevant to the issue)
New assets: