问题
After updating visual studio to version 16.8.2, my solution which uses Post Sharp no longer builds. I didn't upgrade any projects to use .Net 5. Here are the errors I'm seeing:
Severity Code Description Project File Line Suppression State
Error CS0006 Metadata file 'C:\Dev\repos\hinge\HingeSolution\HingeApi\bin\Debug\netcoreapp3.1\HingeApi.dll' could not be found HingeApi-tests C:\Dev\repos\hinge\HingeSolution\HingeApi-tests\CSC 1 N/A
Error MSB4064 The "RuntimeGraphPath" parameter is not supported by the "PrepareForReadyToRunCompilation" task. Verify the parameter exists on the task, and it is a settable public instance property. HingeApi C:\ProgramData\PostSharp\CrossGenPaths\sdk5.0.100-netcoreapp5.0-r5.0.0-win-x64\CrossGen.proj 11
Error MSB4063 The "PrepareForReadyToRunCompilation" task could not be initialized with its input parameters. HingeApi C:\ProgramData\PostSharp\CrossGenPaths\sdk5.0.100-netcoreapp5.0-r5.0.0-win-x64\CrossGen.proj 11
Error The process "dotnet" failed with exit code 1. HingeApi C:\Users\dbdav.nuget\packages\postsharp\6.5.4\build\PostSharp.targets 381
Error error: Unhandled exception (PostSharp.Compiler.Hosting.CommandLine.dll 6.5.4 release | .NET Core 5.0.0 (X64)): Value cannot be null or an empty string. (Parameter 'value') See below for details. HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error System.ArgumentException: Value cannot be null or an empty string. (Parameter 'value') HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at NuGet.Versioning.NuGetVersion.Parse(String value) HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Sdk.Extensibility.PlatformContext.^TTQPa/Ij() in ^f/gziTthOsZk:line 354 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Sdk.Extensibility.PlatformContext.^pFnf8wEt() in ^f/gziTthOsZk:line 114 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Sdk.Extensibility.Project.^pFnf8wEt(ProjectConfiguration[] _0, ProjectInvocationParameters _1) in ^hW2eIAWj:line 795 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Sdk.Extensibility.Project.^pFnf8wEt(ProjectInvocationParameters _0) in ^hW2eIAWj:line 570 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Sdk.Extensibility.Project.LoadProject(ProjectInvocationParameters projectInvocationParameters, Domain& domain) in ^hW2eIAWj:line 541 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation) in C:\src\PostSharp-65\Public\Core\PostSharp.Compiler.Hosting\PostSharpObject.cs:line 256 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
Error at PostSharp.Hosting.Program.ExecuteImpl() in C:\src\PostSharp-65\Public\Core\PostSharp.Compiler.Hosting\Program.cs:line 957 HingeApi C:\Dev\repos\hinge\HingeSolution\HingeApi\POSTSHARP 1
I have tried rebuild, clean and build. Has anyone out there overcome this issue?
回答1:
PostSharp 6.7 is not compatible with .NET 5.0 SDK due to MSBuild changes. .NET 5.0 SDK is installed by Visual Studio Installer when upgrading to VS 16.8.
You can either stay on 3.1 SDK using global.json
or use PostSharp 6.8. It's still in preview, but the RC should be released soon.
More information is available here.
EDIT: Postsharp 6.8 RC was released.
回答2:
Please try to test these:
1) target your project to .net5
, then delete bin and obj folder, after that, rebuild your project again.
2) delete all cache files under C:\Users\xxx(current user)\AppData\Local\Microsoft\VisualStudio\16.0_xxxx\ComponentModelCache
3) disable PostSharp extension under Extensions-->Manage Extensions-->Installed, close VS, restart VS to enable the extension.
4) just update the extension if there are the new release version or reinstall the extension again.
If all the steps do not work, I think you should contact with the PostSharp Team.
来源:https://stackoverflow.com/questions/65079041/postsharp-build-errors-after-update-to-visual-studio-version-16-8-2