Cannot build successfully with 5.1.9: "Failed to get package version for assembly"

avatar's Avatar


23 Apr, 2018 06:19 PM

Full error message as follows:

1>Executing "dotnet" C:\ProgramData\PostSharp\5.1.9\bin.Release\postsharp-netstandard20.dll obj\Debug\netcoreapp2.0\Before-PostSharp\Referrer.dll C:\Working\Repro\NoVersion\Referrer\obj\Debug\netcoreapp2.0\PostSharp\postsharp.config /config C:\ProgramData\PostSharp\5.1.9\bin.Release\postsharp-netstandard20.dll.config /NoLogo /InstallVsx /cancel:Local\postsharp-cancel-13e7f534-b821-4f74-91a2-e89adaafc9b8
1>POSTSHARP(0,0): Error: error: Unhandled exception (postsharp-netstandard20.dll release | .NET Core 2.0.6): Failed to get package version for assembly 'C:\Working\Repro\NoVersion\GateKeeper.API\bin\Debug\netstandard2.0\GateKeeper.API.dll'. See below for details.
1>POSTSHARP(0,0): Error: PostSharp.Sdk.AssertionFailedException: Failed to get package version for assembly 'C:\Working\Repro\NoVersion\GateKeeper.API\bin\Debug\netstandard2.0\GateKeeper.API.dll'.
1>POSTSHARP(0,0): Error: at PostSharp.Sdk.CodeModel.Binding.PackageProjectReference.^zfH7YSbV(PlatformInfoFactory _0, String _1, PlatformInfo _2)
1>POSTSHARP(0,0): Error: at ^rU5MGTYD9kxo.^bhV8(String _0)
1>POSTSHARP(0,0): Error: at PostSharp.Sdk.Extensibility.Project.^pFnf8wEt(ProjectConfiguration[] _0, ProjectInvocationParameters _1)
1>POSTSHARP(0,0): Error: at PostSharp.Sdk.Extensibility.Project.^pFnf8wEt(ProjectInvocationParameters _0)
1>POSTSHARP(0,0): Error: at PostSharp.Sdk.Extensibility.Project.LoadProject(ProjectInvocationParameters projectInvocationParameters, Domain& domain)
1>POSTSHARP(0,0): Error: at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)
1>POSTSHARP(0,0): Error: at PostSharp.Hosting.Program.ExecuteImpl()
1>The process dotnet exited with code 12.

I've included a repro project below, but other than that, I'm deeply confused as to what the cause might be - because if I create an essentially identical project from scratch rather than the one I cut down to a single empty class to make the repro project, it doesn't seem to happen.


  1. Support Staff 1 Posted by PostSharp Techn... on 25 Apr, 2018 10:28 PM

    PostSharp Technologies's Avatar


    Thank you for reporting this issue. We have filed a bug (#16036) and we'll get back to you once we have more information.


  2. 2 Posted by pisethd on 01 May, 2018 05:57 PM

    pisethd's Avatar

    Is there an update for this? I have a similar problem.

  3. Support Staff 3 Posted by PostSharp Techn... on 02 May, 2018 08:51 AM

    PostSharp Technologies's Avatar

    Hello, the cause of this bug in case of Alistair is that there is a NuGet package GateKeeper.API.3.0.0.nupkg of the GateKeeper.API project in the bin folder. PostSharp then wrongly assumes that the reference assembly GateKeeper.API.dll is comming from a NuGet package, which is not the case.

    I assume that the NuGet package there is comming from the dotnet pack command (or msbuild GateKeeper.API.csproj /t:Pack). To work around this issue, you can set the PackageOutputPath MSBuild property to a path, which is not part of the path to the GateKeeper.API.dll file, for example <PackageOutputPath>$(OutputPath)nuget</PackageOutputPath>. (This way, your package will be stored in NoVersion\GateKeeper.API\nuget.

    Piseth, does this work-around work in your case? If not, are you using PostSharp 5.1.9? We have fixed a bug of NuGet package version parsing there. If you do use this version and the work-around doesn't work for you, could you please also share a project reproducing your issue?

    Best regards,

  4. 4 Posted by avatar on 03 May, 2018 07:31 PM

    avatar's Avatar

    Thanks! That workaround seems to solve that problem.

  5. 5 Posted by barathk913 on 14 May, 2018 08:03 AM

    barathk913's Avatar

    Hi Postsharp team/avatar,

    i have a similar problem, can you please let me know where exactly we need to do the workaround which you mentioned. i mean in which file we need to do the workaround changes.


    Also it would be really help if you can share any sample file which contains this workaround.

    thank you in advance.

  6. Support Staff 6 Posted by PostSharp Techn... on 15 May, 2018 01:59 PM

    PostSharp Technologies's Avatar


    You can set the PackageOutputPath in the *.csproj file. for example:


    Best regards,

  7. 7 Posted by PostSharp User1 on 21 May, 2018 06:05 PM

    PostSharp User1's Avatar

    @Alex This doesn't work. It has no effect. The nuget package is still created in the same place.

  8. Support Staff 8 Posted by PostSharp Techn... on 22 May, 2018 01:33 PM

    PostSharp Technologies's Avatar

    Hello, this work-around is for dotnet pack command. Do you use this command to create your nuget package? If not, which way do you use? If yes, please create a new discussion and explain in detail the way to reproduce your problem. It would also help us if you could share your project with us.

    Best regards,

  9. Support Staff 9 Posted by PostSharp Techn... on 07 Jun, 2018 02:59 PM

    PostSharp Technologies's Avatar


    We are going to close this request as there have not been any further updates. Please feel free to reopen the discussion if you need more help.

    PostSharp Team

  10. PostSharp Technologies closed this discussion on 07 Jun, 2018 02:59 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac