If you use Paket instead of NuGet (why? therefore!) you will experience the following difficulties:
Given is the following Solution/Project. It contains a paket.references file containin just one line “PostSharp”, which is
The PostSharp Assembly is added when you your “paket.references” file in the project directory containing just one line “PostSharp”. If you execute “paket install” in your command promt, paket adds PostSharp as reference to the project and modifies the csproj accordingly.
The next time you run a build, PostSharp comes up with this dialog:
Since the VisualStudio PostSharp plugin detects a reference to PostSharp.dll, it expects a packages.config which it can’t find. If you don’t agree, the solution builds successfully but the code won’t be modified by PostSharp.
If you agree, PostSharps adds a packages.config and replaces the existing PostSharp reference with the newest stable one (which probably is not the version you have specified in Paket!).
I posted this on Twitter. The Paket maintainers can’t handle this and PostSharp won’t change this behaviour.
So by now, I don’t see any solution except that Paket users can ask PostSharp to change this behaviour.
//Edit: Have a look at the comments. The unsolved problem is that you have to execute the „install.ps1“. Paket doesn’t do that but NuGet will also remove this feature in a future release.
You can disable the automatic reference fixing of PostSharp by going to menu PostSharp / Options / Advanced and check the option „Disable NuGet dependency verification before build“.
LikeLike
Nope, I tried that before my post. Not working since PostSharp is not activated in the project. Paket downloads the NuGet package and adds the DLL to the project. csproj is attached below. So thats the reason why PostSharp works with projects that have had initially configured by NuGet. New projects only get the references but not the configuration to use PostSharp while compiling.
What do I have to write in the csproj to activate that?
//Edit: cannot post the csproj. You can find it here http://uliarmbruster.de/ConsoleApplication1.csproj
LikeLike
This project won’t compile because tools\PostSharp.targets is not imported. It’s currently added by install.ps1. If you add this Import it should work.
LikeLike
Basically you can see what we do by looking at install.ps1. Nothing we are very proud of but it’s how NuGet is designed…
LikeLike
Ah, thanks. This feature is gonna removed from NuGet. Till then I can execute this manually.
LikeLike
[…] I reported some difficulties that I‘ve experienced with the PostSharp NuGet package when I was using the new package manager […]
LikeLike
[…] ggf. nicht richtig nach der Installation mit Paket. Das ist z.B. bei PostSharp der Fall, was ich hier beschrieben habe. Der geneigte Leser möge bitte bei PostSharp für das offene Issue dazu […]
LikeLike