Search code examples
postsharp

#postsharp Unable to compile after adding PostSharp.Community nuget package (on a Mac)


I'm using a Mac with Visual Studio 2019. I've added nuget packages: PostSharp and PostSharp.Community. I have NOT changed any code. I wasn't NOT prompted to select a license. I'm simply trying to compile, and I get the following errors.

/var/tmp/postsharp/cache/DependencyRestore/6.0.101/net6.0-sdk6.0.101-osx-x64--ps6.10.6.0-cf0d89f.deps.proj : error NU3034: Package 'System.ValueTuple 4.4.0' from source 'https://api.nuget.org/v3/index.json': This package is signed but not by a trusted signer. /var/tmp/postsharp/cache/DependencyRestore/6.0.101/net6.0-sdk6.0.101-osx-x64--ps6.10.6.0-cf0d89f.deps.proj : error NU3037: Package 'System.Security.Cryptography.ProtectedData 4.4.0' from source 'https://api.nuget.org/v3/index.json': The repository primary signature validity period has expired.

My project is targeting framework NetCore3.1. I don't know why PostSharp mentions net6.0.

As soon as I remove the PostSharp packages, it compiles fine.

Any help, would be greatly appreciated.

Thanks, Jason


Solution

  • You probably have .NET 6.0 SDK installed on the machine and it is the active SDK (the highest version is usually used by default). PostSharp always executes under the runtime associated with the current SDK.

    You should use the global.json file to specify SDK for .NET Core 3.1. This would cause PostSharp to run on .NET Core 3.1.

    If this does not help, it means that PostSharp's dependency packages cannot be installed from nuget.org.

    You can disable PostSharp's dependency restore by setting DependencyRestoreDisabled=True (either as env var or MSBuild property) and make sure that the project that was generated into /var/tmp/postsharp/cache/DependencyRestore/<SdkVersion>/<id>.proj has all it's dependencies present in the \var\tmp\postsharp\NuGetFallback directory.

    Disabling the dependency restore disables automated checks and presumes that PostSharp can find all its dependencies on the machine.