Open anwell opened 3 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
There doesn't seem to be a 3.0.100.0 version of that package. There is a 3.1, but that only supports netstandard 1.6. Try switching to the 5.0.0 version of the package, and also try to reload your project after updating the package version.
@joeloff Thanks, yes I know there's no 3.0.100.0 version of the package, this is mainly an example. When single-targeting the build will give a warning that this package cannot be found, and uses the 3.1 version. When multi-targeting it show this warning and also the ResolvePackageDependencies error from the issue. This issue is mainly about the difference in behavior in how the warning gets escalated to an error when adding a 2nd TargetFramework.
Starting with .NET SDK 7.0.200 (I also tested 7.0.201), I encountered the same error even when using dotnet restore
or dotnet build
from the command line. This issue seems to occur when an older version of .NET Framework is mixed with newer versions of .NET / .NET Core. However, multi-targeting works fine with older SDK versions.
I have also experienced the same thing as @maciej-izak. This no longer seems to be just a "cosmetic issue" as the build breaks. I have had to rollback to a previous version of the SDK.
I ran into a similar error with .NET SDK 7.0.404 (different stacktrace, but also inside "ResolvePackageAssets"):
The "ResolvePackageAssets" task failed unexpectedly.
System.ArgumentException: Invalid framework version '4.8/win7-x86'.
at NuGet.Frameworks.NuGetFramework.ParseFrameworkNameParts(IFrameworkNameProvider mappings, String[] parts, String& framework, Version& version, String& profile)
at NuGet.Frameworks.NuGetFramework.ParseFrameworkName(String frameworkName, IFrameworkNameProvider mappings)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.<>c__DisplayClass59_0.<WritePackageDependenciesDesignTime>b__6(String tg)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.<WritePackageDependenciesDesignTime>g__GetPackageDiagnosticLevel|59_2(LockFileLibrary package)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.WritePackageDependenciesDesignTime()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.WriteItemGroup(Action writeItems)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.WriteItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.Write()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheWriter.WriteToCacheFile()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromDisk(ResolvePackageAssets task, Byte[] settingsHash)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task)
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups()
at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore()
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
The reason seems to be this package reference:
<PackageReference Include="Azure.Identity" Version="1.6.0" />
It should report a warning "NU1903 Package 'Azure.Identity' 1.10.0 has a known high severity vulnerability". With recent package "1.10.4", the error does not happen.
The project has target frameworks net48;net6.0-windows
.
Unfortunately, I could not reproduce it with a simple sample project. Is it related to the initial bugreport?
I could reproduce it, see attached sample. NugetTest.zip
Seems to happen only if the project has type "WinExe", and I defined .NET 7 SDK in "global.json". With SDK8, this does not happen, so this would be a possible workaround for me.
When adding a 2nd TargetFramework in the simple csproj file below, Visual Studio shows the following exception. When using a single TargetFramework, this error goes away.
It looks like the problem is that while this code is reading a warning log message, NugetFramework.Parse() hits an exception because it cannot parse framework version in the format "v4.6.2/win7-x86":
https://github.com/dotnet/sdk/blob/cf2f60514e8e6f16a67ca6cd10c52b52bf23ac68/src/Tasks/Microsoft.NET.Build.Tasks/ResolvePackageDependencies.cs#L253-L263
Full callstack from debugging:
This issue is mostly comsetic, because I can still restore/build using
dotnet restore
anddotnet build
from the command line.