Reputation: 41
Since upgrading to the latest Visual Studio (16.8.1), I can no longer compile any projects that use PostSharp.
I receive the following build errors (for PostSharp v6.7.11 AND for 6.8.1-preview):
1>POSTSHARP : error : error: Unhandled exception (PostSharp.Compiler.Hosting.CommandLine.dll 6.8.1 release | .NET Core 5.0.0 (X64)): Could not load file or assembly 'NuGet.Versioning, Version=5.8.0.6823, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. See below for details.
1>POSTSHARP : error : System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.Versioning, Version=5.8.0.6823, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
1>POSTSHARP : error : File name: 'NuGet.Versioning, Version=5.8.0.6823, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
1>POSTSHARP : error : at PostSharp.Sdk.Extensibility.Platforms.SdkAssemblyRepository..ctor(String installedFrameworkDocumentPath, String visualStudioVersionString)
1>POSTSHARP : error : at PostSharp.Sdk.Extensibility.PlatformContext..ctor(Project project, String installedFrameworkDocumentPath, String visualStudioVersion) in C:\src\PostSharp-68\Public\Core\PostSharp.Compiler.Engine\Sdk\Extensibility\PlatformContext.cs:line 103
1>POSTSHARP : error : at PostSharp.Sdk.Extensibility.Project.Initialize(ProjectConfiguration[] projectConfigurations, ProjectInvocationParameters projectInvocationParameters) in C:\src\PostSharp-68\Public\Core\PostSharp.Compiler.Engine\Sdk\Extensibility\Project.cs:line 903
1>POSTSHARP : error : at PostSharp.Sdk.Extensibility.Project.Initialize(ProjectInvocationParameters projectInvocationParameters) in C:\src\PostSharp-68\Public\Core\PostSharp.Compiler.Engine\Sdk\Extensibility\Project.cs:line 599
1>POSTSHARP : error : at PostSharp.Sdk.Extensibility.Project.LoadProject(ProjectInvocationParameters projectInvocationParameters, Domain& domain) in C:\src\PostSharp-68\Public\Core\PostSharp.Compiler.Engine\Sdk\Extensibility\Project.cs:line 570
1>POSTSHARP : error : at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation) in C:\src\PostSharp-68\Public\Core\PostSharp.Compiler.Hosting\PostSharpObject.cs:line 256
1>POSTSHARP : error : at PostSharp.Hosting.Program.ExecuteImpl() in C:\src\PostSharp-68\Public\Core\PostSharp.Compiler.Hosting\Program.cs:line 958
Note that I have NOT converted any projects to .NET 5.0. I just updated Visual Studio to the latest version.
Does anyone know how to resolve this? Thanks
Upvotes: 2
Views: 1065
Reputation: 335
Change the SDK used to build your project by adding a new file in the same directory as your .sln file called global.json:
{
"sdk": {
"version": "3.1.404",
"rollForward": "latestPatch"
}
}
Install the latest version of the .Net core SDK here: https://dotnet.microsoft.com/download/dotnet-core/3.1
Postsharp 6.7 does not support .Net 5 SDK.
See this article from PostSharp for more information: https://blog.postsharp.net/post/updating-to-vs-168-breaks-build.html
Thanks Daniel Balas for answering this question. https://stackoverflow.com/a/65087786/1247572
Upvotes: 2
Reputation: 41
This was resolved by cleaning the solution before building. Yes, I should have tried this immediately, but in a solution of ~70 projects, this PostSharp error was the only new build error.
Upvotes: 2