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

[Preview] Unable to restore packages from feeds with encrypted passwords on windows #23498

Closed
shadow-cs opened this issue Jan 19, 2022 · 64 comments
Assignees

Comments

@shadow-cs
Copy link

Describe the bug

After the recent update of VS Preview (I got the telemetry prompt earlier today), I'm not able to restore packages from feeds that use an encrypted password.

To Reproduce

  • Make sure some password-protected feeds are registered and they use encrypted password
  • Prepare a project that requests something from the feed
  • Run dotnet nuget locals all --clear just in case to make sure the restore operation is needed
  • Run dotnet restore

Exceptions (if any)

  Retrying 'FindPackagesByIdAsyncCore' for source 'https://nuget.xyz.com/repository/nuget-prod/FindPackagesById()?id='Package'&semVerLevel=2.0.0'.
  Password decryption is not supported on .NET Core for this platform. The following feed uses an encrypted password: 'repo-name'. You can use a clear text password as a workaround.
    Windows Data Protection API (DPAPI) is not supported on this platform.

Detailed exception.

Further technical details

  • Windows 10 21H2
  • SDK 6.0.200-preview.21617.4

Workaround

Use global.json and downgrade to 6.0.100.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NuGet untriaged Request triage from a team member labels Jan 19, 2022
@shadow-cs
Copy link
Author

shadow-cs commented Jan 19, 2022

I cannot tun VS 2022 Preview anymore fixed it, tried repairing the installation but I got an error that Microsoft.AspNetCore.TargetingPack.6.0.6.0.0-rtm.21526.8 cannot be installed. So I was wondering whether this could be related.

@cek-cek
Copy link

cek-cek commented Feb 16, 2022

The same issue on multiple environments after today's update to 6.0.2 from stable channel.
One would expect that the platform sharing the same name with Windows Data Protection API would actually be supported 👀

@jasase
Copy link

jasase commented Feb 17, 2022

We have the same problem. All projects currently not building on our OnPremise Build-Servers

@wazzamatazz
Copy link

We are also seeing this issue in our on-premises build servers using an authenticated TeamCity feed after installing VS 2022 17.1 build tools.

@m8ram
Copy link

m8ram commented Feb 18, 2022

I'm getting the same error after installing dotnet 6.0.2 via chocolatey (choco install dotnet-sdk).

@calebcartwright
Copy link
Contributor

Same. Will add that we're seeing this behavior on Win Server 2016 environments, though doesn't seem like the issue occurs on Server 2022

@george-chakhidze
Copy link

In my case it is not even a feed password, it's http_proxy.password argument that is encrypted.

@Falco20019
Copy link

Falco20019 commented Feb 21, 2022

Same for us since updating to SDK 6.0.200 (not preview) on our development machines. When I switch back to 6.0.101 it works. Don't have 6.0.102 to test against (and don't want to install), so it definitely happened between 6.0.101 and 6.0.200.

@Falco20019
Copy link

/CC @sfoslund Since this might be related to the changes from #22251

@saurla
Copy link

saurla commented Feb 21, 2022

I debugged this issue with dotnet restore -v diag command. Here is the most inner exception in the stack trace:

System.PlatformNotSupportedException: Windows Data Protection API (DPAPI) is not supported on this platform.
    at System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope)
    at NuGet.Configuration.EncryptionUtility.DecryptString(String encryptedString)
    at NuGet.Configuration.PackageSourceCredential.get_Password()

So the problem seems to be the System.Security.Cryptography.ProtectedData.dll. The dotnet installation contains the non platform specific version of the DLL at the root level (C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll). The implementation of this DLL just throws the System.PlatformNotSupportedException since the ProtectedData is only supported on Windows platform.

The Windows platform specific DLL is found under the runtimes directory (C:\Program Files\dotnet\sdk\6.0.200\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll).

For some reason the dotnet executable is using the non platform specific version of the DLL and not the Windows platform specific version.

I was able to workaround the issue by removing the non platform specific DLL at C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll. After this, the dotnet started using the correct one from C:\Program Files\dotnet\sdk\6.0.200\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll and restore started working again.

EDIT: Environment where I tested is Windows Server 2016.

@saurla
Copy link

saurla commented Feb 22, 2022

I tried to troubleshoot this issue further using dotnet-trace tool to see how assembly loading goes. I traced the dotnet restore command using command dotnet-trace collect --providers Microsoft-Windows-DotNETRuntime:4 -- dotnet restore. I first traced it with the dotnet version 6.0.200 which is not working and then with version 6.0.101 which is working. I noticed that the traces were quite much different. Unfortunately I'm not familiar enough with .NET assembly loading to make anything more useful out of this but maybe somebody can get something from this. I have filtered to show only the events that contain text ProtectedData.

Trace of not working version (6.0.200)

Event Name                                                    	Time MSec	Process Name        	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/KnownPathProbed	1,005.717	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" FilePath="C:\Program Files\dotnet\sdk\6.0.200\en-US\System.Security.Cryptography.ProtectedData.resources.dll" Source="SatelliteSubdirectory" Result="-2,147,024,894" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/KnownPathProbed	1,006.419	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" FilePath="C:\Program Files\dotnet\sdk\6.0.200\en\System.Security.Cryptography.ProtectedData.resources.dll" Source="SatelliteSubdirectory" Result="-2,147,024,894" ActivityID="/#3184/1/203/" 

Event Name                                                        	Time MSec	Process Name        	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,003.293	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="FindInLoadContext" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/200/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,004.110	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="FindInLoadContext" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/200/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,004.297	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="AssemblyLoadContextLoad" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="Success" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" ErrorMessage="" ActivityID="/#3184/1/200/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,005.267	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" Stage="FindInLoadContext" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,005.417	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" Stage="AssemblyLoadContextLoad" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,005.567	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Culture=neutral, PublicKeyToken=null" Stage="FindInLoadContext" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="Success" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" ErrorMessage="" ActivityID="/#3184/1/202/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,005.772	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" Stage="ResolveSatelliteAssembly" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,005.825	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" Stage="AssemblyLoadContextResolvingEvent" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,005.899	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" Stage="AppDomainAssemblyResolveEvent" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,006.101	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" Stage="FindInLoadContext" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/203/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,006.217	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" Stage="AssemblyLoadContextLoad" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/203/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,006.472	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" Stage="ResolveSatelliteAssembly" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/203/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,006.525	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" Stage="AssemblyLoadContextResolvingEvent" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/203/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	1,006.590	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" Stage="AppDomainAssemblyResolveEvent" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#3184/1/203/" 

Event Name                                          	Time MSec	Process Name        	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,003.231	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="NuGet.Configuration, Version=6.1.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" ActivityID="/#3184/1/200/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,004.044	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" RequestingAssembly="System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext="Default" ActivityID="/#3184/1/200/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,004.427	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" AssemblyPath="" RequestingAssembly="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" ActivityID="/#3184/1/201/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,005.199	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,005.498	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Culture=neutral, PublicKeyToken=null" AssemblyPath="" RequestingAssembly="" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext="" ActivityID="/#3184/1/202/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,006.037	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" ActivityID="/#3184/1/203/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	1,006.285	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Culture=neutral, PublicKeyToken=null" AssemblyPath="" RequestingAssembly="" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext="" ActivityID="/#3184/1/203/1/" 

Event Name                                         	Time MSec	Process Name        	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,004.228	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" DURATION_MSEC="0.184" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" RequestingAssembly="System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext="Default" Success="True" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" Cached="False" ActivityID="/#3184/1/200/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,004.359	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="NuGet.Configuration, Version=6.1.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Success="True" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" Cached="False" ActivityID="/#3184/1/200/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,004.723	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" DURATION_MSEC="0.295" ClrInstanceID="3" AssemblyName="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" AssemblyPath="" RequestingAssembly="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Success="True" ResultAssemblyName="netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" ResultAssemblyPath="C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.2\netstandard.dll" Cached="False" ActivityID="/#3184/1/201/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,005.634	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" DURATION_MSEC="0.135" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Culture=neutral, PublicKeyToken=null" AssemblyPath="" RequestingAssembly="" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext="" Success="True" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" Cached="False" ActivityID="/#3184/1/202/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,005.955	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Success="False" ResultAssemblyName="" ResultAssemblyPath="" Cached="False" ActivityID="/#3184/1/202/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,006.347	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" DURATION_MSEC="0.062" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData, Culture=neutral, PublicKeyToken=null" AssemblyPath="" RequestingAssembly="" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext="" Success="True" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.200\System.Security.Cryptography.ProtectedData.dll" Cached="True" ActivityID="/#3184/1/203/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	1,006.645	Process(3184) (3184)	HasStack="True" ThreadID="3,424" ProcessorNumber="0" ClrInstanceID="3" AssemblyName="System.Security.Cryptography.ProtectedData.resources, Version=5.0.0.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.200\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #4" Success="False" ResultAssemblyName="" ResultAssemblyPath="" Cached="False" ActivityID="/#3184/1/203/" 

Trace of working version (6.0.101)

Event Name                                                    	Time MSec	Process Name          	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/KnownPathProbed	  825.565	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" FilePath="C:\Program Files\dotnet\sdk\6.0.101\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" Source="ApplicationAssemblies" Result="0" ActivityID="/#18640/1/291/1/" 

Event Name                                                        	Time MSec	Process Name          	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	  824.507	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="FindInLoadContext" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.101\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #5" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#18640/1/291/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	  825.610	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="FindInLoadContext" AssemblyLoadContext="Default" Result="AssemblyNotFound" ResultAssemblyName="" ResultAssemblyPath="" ErrorMessage="Could not locate assembly" ActivityID="/#18640/1/291/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	  825.656	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="ApplicationAssemblies" AssemblyLoadContext="Default" Result="Success" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.101\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" ErrorMessage="" ActivityID="/#18640/1/291/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/ResolutionAttempted	  825.968	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Stage="AssemblyLoadContextLoad" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.101\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #5" Result="Success" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.101\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" ErrorMessage="" ActivityID="/#18640/1/291/" 

Event Name                                          	Time MSec	Process Name          	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	  824.456	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="NuGet.Configuration, Version=6.0.0.280, Culture=neutral, PublicKeyToken=31bf3856ad364e35" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.101\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #5" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.101\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #5" ActivityID="/#18640/1/291/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Start	  825.161	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="C:\Program Files\dotnet\sdk\6.0.101\System.Security.Cryptography.ProtectedData.dll" RequestingAssembly="System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" AssemblyLoadContext="Default" RequestingAssemblyLoadContext="Default" ActivityID="/#18640/1/291/1/" 

Event Name                                         	Time MSec	Process Name          	Rest  
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	  825.759	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" DURATION_MSEC="0.598" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="C:\Program Files\dotnet\sdk\6.0.101\System.Security.Cryptography.ProtectedData.dll" RequestingAssembly="System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" AssemblyLoadContext="Default" RequestingAssemblyLoadContext="Default" Success="True" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.101\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" Cached="False" ActivityID="/#18640/1/291/1/" 
Microsoft-Windows-DotNETRuntime/AssemblyLoader/Stop	  826.033	Process(18640) (18640)	HasStack="True" ThreadID="21,544" ProcessorNumber="0" ClrInstanceID="6" AssemblyName="System.Security.Cryptography.ProtectedData, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" AssemblyPath="" RequestingAssembly="NuGet.Configuration, Version=6.0.0.280, Culture=neutral, PublicKeyToken=31bf3856ad364e35" AssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.101\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #5" RequestingAssemblyLoadContext=""MSBuild plugin C:\Program Files\dotnet\sdk\6.0.101\NuGet.Build.Tasks.dll" Microsoft.Build.Shared.MSBuildLoadContext #5" Success="True" ResultAssemblyName="System.Security.Cryptography.ProtectedData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" ResultAssemblyPath="C:\Program Files\dotnet\sdk\6.0.101\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" Cached="False" ActivityID="/#18640/1/291/" 

@billhenn
Copy link

This broke all our GitHub Actions jobs today after GitHub appeared to upgrade their .NET SDKs to use v6.0.200 instead of v6.0.101. We can no longer run our build scripts due to this exception.

I sure hope Microsoft and GitHub can get a bug fix out ASAP!

@baronfel
Copy link
Member

Hello everyone - this is a very concerning report, the team is currently investigating what some solutions might be. We're currently working on reproducing the error before we commit to a solution. Thank you especially to @saurla for the investigation and @shadow-cs for the initial report.

@baronfel
Copy link
Member

Notes for team - the reference to System.Security.Cryptography.ProtectedData is being added here, but binlogs show both the OS-agnostic as well as the runtime-specific outputs being added to the redist project. We will likely need to look at post-build, pre-pack hooks to remove this dll, and then look into automated validation of other such dependencies (where an OS-agnostic DLL would error, but a correct OS-specific DLL is present).

An alternative might be to change the SDK layout at the dotnet/installer repo - so that the OS-agnostic dll could be kept for macos/linux builds but removed from the windows builds.

@saurla
Copy link

saurla commented Feb 23, 2022

One further note from me. The OS agnostic version of System.Security.Cryptography.ProtectedData.dll is also present in the 6.0.101 where everything works fine. There the correct dll is however correctly loaded from the runtimes\win\lib\netstandard2.0 directory. So the dll layout seemed to be same in both 6.0.101 and 6.0.200 but loading was still done differently.

@actionthomas
Copy link

The problem is also present on .net 7 preview 1 (7.0.100-preview.1.22110.4)

@squid-box
Copy link

We just encountered this on our build pipelines in Azure DevOps, where the agent image windows-2022 appears to have updated to use VS 2022 17.1 build tools.

@baronfel
Copy link
Member

@saurla the OS agnostic dll has been in that location since at least the 5.0.1xx SDKs, my running theory is that we just weren't using any data protection APIs in any SDK code paths until the PR linked above that would highlight this issue.

@saurla
Copy link

saurla commented Feb 23, 2022

@baronfel Ok. But I think it's expected behavior that OS agnostic dll of ProtectedData is found from the "root" folder and OS specific one from the runtimes when referencing that NuGet. I tried if I could reproduce this issue with very simple .NET 6 project that references the System.Security.Cryptography.ProtectedData.dll NuGet and only call ProtectedData.Protect and ProtectedData.Unprotect methods. When I build this project I get similar file layout as the SDK 6.0.200 has. So I have a OS agnostic version of System.Security.Cryptography.ProtectedData.dll at the root folder where I also have my built project DLL. Then in the runtimes\win\lib\netstandard2.0 I have the OS specific version of the dll. This project runs fine and loads the correct DLL.

@baronfel
Copy link
Member

I'm having a hard time reproducing this - it would be very helpful if we could get the following data from anyone experiencing this:

  • set COREHOST_TRACE=1
  • set your SDK to 6.0.1xx via global.json or some other mechanism
  • set COREHOST_TRACEFILE=6.0.1xx_trace.txt
  • run a dotnet restore (which should be successful)
  • clean your project with dotnet clean
  • set COREHOST_TRACEFILE=6.0.2xx_trace.txt
  • set your SDK to 6.0.2xx via global.json or some other mechanism
  • run a dotnet restore (which should fail)

@Falco20019
Copy link

Falco20019 commented Feb 24, 2022

I'm currently ill, so I can't do it right now. For whoever is doing it: dotnet clean is not enough. You will also have to do a dotnet nuget locals http-cache -c. Otherwise, it will still work when the cache is up to date.

@baronfel I assume that's the thing you are missing and why it's hard for you to reproduce right now.

@saurla
Copy link

saurla commented Feb 24, 2022

Even running dotnet nuget locals http-cache -c might not be enough. These steps should be sufficient:

  • Make sure you have some credentials set to NuGet feed. You can set them for example to default nuget.org feed. It does not matter what the credentials are: dotnet nuget update source nuget.org --username test --password test
  • dotnet clean
  • Make sure obj folder is removed or empty. I noticed that sometimes dotnet clean does not clean it completely.
  • dotnet nuget locals http-cache -c
  • Remove the NuGet file cache: rd /S /Q %USERPROFILE%\.nuget\packages
  • Run dotnet restore (should fail with version 6.0.200)

@saurla
Copy link

saurla commented Feb 24, 2022

I started looking again through the assembly loading trace I pasted in comment #23498 (comment). I noticed that the used AssemblyLoadContext is MSBuildLoadContext. That lead me to think that maybe the problem could be at the MSBuild side instead. I noticed that SDK 6.0.200 uses MSBuild version 17.1.0 and SDK 6.0.101 uses version 17.0.0. I tried to replace MSBuild DLL files of 6.0.200 with the ones from 6.0.101 and the dotnet restore started working. So maybe the problem is in the MSBuild side instead?

I noticed that in the MSBuild side there was this one change between 17.0.0 and 17.1.0 to the MSBuildLoadContext dotnet/msbuild@3bb10b7. There the version comparison was changed from exact match to exact or greater. The MSBuild depends on version 4.0.2 of System.Security.Cryptography.ProtectedData.dll but dotnet SDK depends on version 5.0.0. So the version present in the SDK is 5.0.0. In previous versions of MSBuildLoadContext the version of System.Security.Cryptography.ProtectedData.dll would not have matched and DLL would not have been loaded from the same folder where MSBuild.dll is located. But in the new version it will load that one. This is just a theory as I'm not on expert when it comes to how assembly loading in .NET works. I do not have a development environment for SDK and MSBuild so that I could test if reverting this change would fix the problem.

@actionthomas
Copy link

@baronfel Here are the files

@baronfel baronfel self-assigned this Feb 24, 2022
@baronfel baronfel added Servicing-consider and removed untriaged Request triage from a team member labels Feb 24, 2022
@rainersigwald
Copy link
Member

The MSBuild-side revert is merged to daily builds of the 6.0.2xx SDK, and the next patch release of the .NET SDK should have the fix.

@MrDoe
Copy link

MrDoe commented Mar 30, 2022

We are currently having the same issue with 6.0.201 SDK. We had to go back to 6.0.101 via global.json for being able to restore nuget packages behind our proxy server.

@cateyes99
Copy link

Having the same issue with the SDK. 6.0.201 on Windows 10 Enterprise. @saurla your workaround really helps. Thank you.

Hope this bug gets fixed asap.

@MrBjorn
Copy link

MrBjorn commented Apr 1, 2022

We have the same problem on Windows, .net6. It fails with SDK. 6.0.201, and works with SDK. 6.0.101. But its many changes to our build scripts to stay on a fixed version, and not the latest .net. (we use cake as well).

Any solution on this? Seems its been around for quite some time now this bug?

@ABAG603
Copy link

ABAG603 commented Apr 1, 2022

@MrBjorn no need to change your build scripts. Just install 6.0.101 on all of your build servers and pin it by adding global.json to the root of your repo.
{ "sdk": { "version": "6.0.101" } }

@StefanOssendorf
Copy link

@ABAG603 I'm not sure if it's sufficient in all cases. Our global.json looks like this:

{
    "sdk": {
        "version": "6.0.101",
        "rollForward": "disable",
        "allowPrerelease": false
    }
}

@MrBjorn
Copy link

MrBjorn commented Apr 1, 2022

@MrBjorn no need to change your build scripts. Just install 6.0.101 on all of your build servers and pin it by adding global.json to the root of your repo. { "sdk": { "version": "6.0.101" } }

Thanks for the fast and good reply! I added this and it worked. It seems like I had to add it to my unit test project as well.

Well, I hope MS solves this asap., its not optimal to be stuck on a fixed .NET version.

@Shane32
Copy link

Shane32 commented Apr 11, 2022

I had this problem also on a new computer with a new installation of Visual Studio - whatever version was available a week ago. (Now it is 17.1.3, but I'm not sure if there was an update or not)

.NET SDK 6.0.201 was the only SDK installed. I installed .NET SDK 6.0.101. The problem is gone now. I did not need to add a global json file.

@Shane32
Copy link

Shane32 commented Apr 12, 2022

I had this problem also on a new computer with a new installation of Visual Studio - whatever version was available a week ago. (Now it is 17.1.3, but I'm not sure if there was an update or not)

.NET SDK 6.0.201 was the only SDK installed. I installed .NET SDK 6.0.101. The problem is gone now. I did not need to add a global json file.

Another computer spontaneously started having this problem. It has 17.1.3. Installing .NET SDK 6.0.101 did not alone fix the problem.

@shadow-cs
Copy link
Author

Just tested .NET SDK 6.0.202 and everything appears to be in order in this version 😉.

@Falco20019
Copy link

The changelog for MSBuild looks promising. Will try it tomorrow.

@norgie
Copy link

norgie commented Apr 13, 2022

Has anyone dared updating to 6.0.4 yet? Does it solve the issue we're discussing here?

@Falco20019
Copy link

Falco20019 commented Apr 13, 2022

Yes it does. .NET SDKs 6.0.104 and 6.0.202 will also include the fix. Updating VS 2022 to 17.1.4 will also pull the needed version.

I just removed the global.json pinning everywhere.

@norgie
Copy link

norgie commented Apr 13, 2022

@Falco20019

Sweet!

@StefanOssendorf
Copy link

Nice it's released. Does someone know when the hosted agents get updated with this release?

@hamarb123
Copy link

hamarb123 commented Apr 15, 2022

6.0.202/104 is not working for me,
No matter how many times I re-add it I'm getting Client certificate configuration password for the package source 'NAMEHERE' cannot be decrypted
How do I fix this?
Edit:
This only happens in some projects
The project this happens on has a Nuget.config that removes all sources, so this shouldn't be an issue to start with

@Falco20019
Copy link

@hamarb123 Sounds like a different issue since it now has access to the DAPI (different message). So I'm not sure if it's not better to open a separate one.

Is it working if you place a global.json and set the SDK to 6.0.101?

@hamarb123
Copy link

Is it working if you place a global.json and set the SDK to 6.0.101?

Just tested this, it doesn't.
I can repro on dotnet/roslyn with the src\NuGet\Microsoft.Net.Compilers.Toolset project.
Can you see if you have this issue too, or if it's just on my end (you may have to change the sdk version in their global.json).

@randyklex
Copy link

Relentless searching - this seems to be exactly my problem..
However, using this docker file I get this exception

FROM mcr.microsoft.com/dotnet/sdk:6.0.202-bullseye-slim as builder
WORKDIR /src
COPY . .
RUN dotnet nuget add source "https://nuget.pkg.github.com/[me]/index.json" --name github --username [me]--password ${GITHUB_TOKEN} --store-password-in-clear-text
error: Password encryption is not supported on .NET Core for this platform. The following feed try to use an encrypted password: 'github'. You can use a clear text password as a workaround.
error:   Encryption is not supported on non-Windows platforms.

None of the workarounds worked either.
I got this error with 6.0.201 SDK, and even the suggested fallback to 6.0.101.
Is it something specific to the bullseye image?

@Falco20019
Copy link

Falco20019 commented Apr 17, 2022

Bullseye is Debian 11 and as the message states, encrypted passwords only work on windows images. So it's not an issue with the current version but that the API is just not available.

Either use a windows based image if you are on a windows host or use the unencrypted password flag.

The tags with nanoserver-ltsc2022 and windowsservercore-ltsc2022 are for example windows based and would support it. If your host is set to use windows containers, you can even just use latest as it will also use the Nano Server 2022 amd64 variant.

To use windows containers, right-click on your docker icon and switch the daemon. These are only hostable on windows machines.

@randyklex
Copy link

I'm using --store-password-in-clear-text. Is that what you mean by add the flag?

@Falco20019
Copy link

Sorry, I missed it at the end of the line there. Yes, that's the flag that should work

@randyklex
Copy link

randyklex commented Apr 17, 2022

No problem. Yeah, it doesn't work for me with those commands from my dockerfile.

I am using a GitHub action passing the GITHUB_TOKEN as a --build-arg and then using that in the actual docker file that's described above.

Hhhmmm??

-- edit: 2022-04-18
Pulling the 6.0.202-bullseye-slim docker image and exec'ing into the container, I'm able to manually add the source just fine.
However, when the command is run w/ docker build --build-args GITHUB_TOKEN=[securevalue] it fails. I probably won't update this anymore since it appears to be a problem w/ how the Dockerfile is constructed rather the SDK since from within the container the command works.

@baronfel
Copy link
Member

Since this fix is out on patch releases of 6.0.1xx and 6.0.2xx SDKs, I'm going to close this issue since it dealt specifically with loading the correct version of the DPAPI DLLs.

If folks have any more issues with NuGet key handling, please raise another issue to track that.

Forgind added a commit to dotnet/msbuild that referenced this issue Apr 19, 2022
Fixes #4081 and Fixes #1887; progress towards #5037

Context
MSBuild doesn't currently respect .deps.json files for plugins (tasks). This can lead to incorrect versions of assemblies being found as finding the AnyCPU version of an assembly instead of the windows-specific version.

Changes Made
Use AssemblyDependencyResolver as a second pass (after looking for "well-known assemblies") to automatically use the deps.json file to find the right assembly.

Testing
Verified that for a task assembly with a rid-specific dependency, it finds the rid-specific dependency as specified by the deps.json file. Also verified that it can find native assemblies and that the issue that inspired this (dotnet/sdk#23498) no longer reproduces after giving nuget a .deps.json file specifying the correct version.
@tharpooljha
Copy link

We had to pass the --build-arg flag to get the secret to work. We were passing as secrets on github actions. 'secrets: |' --build-arg failed on 6.0, but was succesful on 6.022.

    - name: Docker Build
        id: build
        run: |
          docker build . -f ${{ github.workspace }}/containers/docker/product.api.dev.dockerfile -t ${{ env.REGISRY_URL }}/ecm/product:${{ env.SHORT_SHA }} -t ${{ env.REGISRY_URL }}/ecm/product:dev --build-arg ACCESS_TOKEN=${{ env.AZDEVOPS_TOKEN }}
       ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests