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

[5.0.100-rc.1.20454.5] Build/Launch NuGetPackageExplorer failed due to exception "Could not find type 'System.Runtime.Versioning.MinimumOSPlatformAttribute'" #13458

Closed
jiangzeng01 opened this issue Sep 9, 2020 · 6 comments
Assignees

Comments

@jiangzeng01
Copy link

jiangzeng01 commented Sep 9, 2020

Application Name: NuGetPackageExplorer
OS: Windows 10 RS5
CPU: X64
.NET Build Number: 5.0.100-rc.1.20454.5
App Source on GitHub link: https://github.com/NuGetPackageExplorer/NuGetPackageExplorer (this source is new, we test old version )
(We found this bug when we are trying to upgrade the NuGetPackageExplorer app, and build with latest RC1 SDK.)

Verify Scenarios:
1). Windows 10 RS5 X64 + .NET Core SDK build 5.0.100-rc.1.20454.5: Fail
2). Windows 10 RS5 X64 + .NET Core SDK build 5.0.100-preview.8.20417.9-win-x64: Pass

Repro Machine:
See in bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1198579/

Repro steps:
open command prompt window.
Run "cd C:\Users\Appcompat\Documents\NuGetPackageExplorer" command, navigate to the app path.
Run "dotnet NuGetPackageExplorer.dll" to lanuch the app.
Expected Result:
Open NuGetPackageExplorer successful.
Actual Result:
Unable to lanuch NuGetPackageExplorer

Exception Log:

Unhandled exception. System.TypeLoadException: Could not load type 'System.Runtime.Versioning.MinimumOSPlatformAttribute' from assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
   at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
   at System.Reflection.CustomAttributeExtensions.GetCustomAttributes[T](Assembly element)
   at NuGetPe.Utility.AppVersionTelemetryInitializer..ctor() in C:\Users\Appcompat\Downloads\NuGetPackageExplorer-5.8.2\NuGetPackageExplorer-5.8.2\Core\Utility\AppVersionTelemetryInitializer.cs:line 19
   at NuGetPe.DiagnosticsClient.Initialize() in C:\Users\Appcompat\Downloads\NuGetPackageExplorer-5.8.2\NuGetPackageExplorer-5.8.2\Core\Utility\DiagnosticsClient.cs:line 17
   at PackageExplorer.App..ctor() in C:\Users\Appcompat\Downloads\NuGetPackageExplorer-5.8.2\NuGetPackageExplorer-5.8.2\PackageExplorer\App.xaml.cs:line 30
   at PackageExplorer.App.Main()

Findings :
We search the this change on Github and found this class name is changed from MinimumOSPlatformAttribute to SupportedOSPlatformAttribute:
#12775

We also created a simple reproduce project:
https://github.com/jiangzeng01/MinimumOSPlatformAttributeExceptionSample.git

MinimumOSPlatformAttribute OSPlatform = new MinimumOSPlatformAttribute("win-x64");
Console.WriteLine(OSPlatform.PlatformName);
Console.WriteLine("Hello World!");

When we set sdk version as "5.0.100-preview.8.20417.9" in global.json file, the project can be built and run successful:

{
  "sdk": {
    "version": "5.0.100-preview.8.20417.9"
  }
}

If we change the sdk version to "5.0.100-rc.1.20454.5", we will get exception when building the app.

{
  "sdk": {
    "version": "5.0.100-rc.1.20454.5"
  }
}

Exception from the sample code above :

C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\Program.cs(10,13): error CS0246: The type or namespace name 'MinimumOSPlatformAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample.csproj]
C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\Program.cs(10,57): error CS0246: The type or namespace name 'MinimumOSPlatformAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Appcompat\source\repos\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample\MinimumOSPlatformAttributeExceptionSample.csproj]

cc @dotnet-actwx-bot

@jiangzeng01
Copy link
Author

@adamsitnik We found that it was changed in PR #12775.
It looks by design, and it caused issue when we use the latest RC1 SDK to build the app which are using property "MinimumOSPlatformAttribute".
We need to confirm and see if any break change document for this?

@adamsitnik
Copy link
Member

Hi @jiangzeng01

You are right, this is a breaking change that I've introduced in dotnet/runtime#40371 to runtime and in #12775 to the SDK.

We are not planning to revert the rename, it's going to stay this way. cc @jeffhandley

Could you please switch to the new name?

I apologize for any inconvenience you had,
Adam

@jiangzeng01
Copy link
Author

@adamsitnik Thanks for confirmation! As this is a breaking change, could you please provide the breaking change announcement?

@jeffhandley
Copy link
Member

@jiangzeng01 We did not yet write it, since we don't typically produce breaking change documents between preview releases. But due to the impact this has caused, I've labeled dotnet/runtime#40360 with needs-breaking-change-doc-created to capture that task and we will get it written very soon.

@jiangzeng01
Copy link
Author

@jeffhandley Thanks a lot!

@jiangzeng01
Copy link
Author

Update breaking change document:
dotnet/docs#20635

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

3 participants