Details about the issue with PostSharp and Paket
Table of Contents
-
Prerequisites
initial steps to prepare a demo project for this issue -
Problem
describes the issue in detail -
Conclusion
summary of the issue and conjecture of the root cause -
Workarounds and tracking the solving efforts
audits the solutions hints and efforts to solve the issue
Prerequisites
-
Create a new project with an empty class named
ClassUsingPostSharp
-
Add via NuGet the package
PostSharp.Patterns.Common
-
Add a new integer property named
Counter
and put the PostSharpRangeAttribute
on it[Range(1, 7)] public int Counter { get; set; }
-
Add via NuGet the package
xUnit
-
Add a unit-test for the functionality of PostSharp
by verifying whether an exception is thrown when theCounter
property is set to a value outside the given range -
Run the unit-test to check that everything is green
-
Add Paket in Magic Mode
-
Run
paket convert-from-nuget
-
Run the unit-test to check that everything is still green
- also after closing and re-opening Visual Studio this is still the case
- also after Clean Solution, Rebuild Solution
-
put all files under source control
- use a reasonable
.gitignore
for Visual Studio projects - that was done by each step in this repo here)
- use a reasonable
Problem
-
Verify with
git status
that nothing was forgotten -
Run
git clean -dxf
to cleanup all intermediate outputs somewhere in the developing tree -
Run the unit-test again and now it is red!
-
Add via NuGet the package
PostSharp.Patterns.Common
-
Run the unit-test again and now it is back green
-
With
git status
you see that only the filesrc/PostSharpAndPaket/PostSharpAndPaket.csproj
was modified -
With
git reset --hard
we take back the changes to ensure a clean workspace (from git perspective) -
Run the unit-test again and this time it is still green
-
Again we get back the issue by running
git clean -dxf
Conclusion
- This means, that something under the hood in the
obj
,bin
, .. folder is necessary for PostSharp. - The same issue a co-worker and the CI server will have.
Who can help?
Workarounds and tracking the solving efforts
Easier access to build and run
Hint: for all commands below open a Developer Command Prompt for Visual Studio and navigate to the project root folder
Build via CLI
-
run build with
msbuild .\src\PostSharpAndPaket\PostSharpAndPaket.sln
xUnit Console Runner
-
with commit
56444b
("add xUnit console runner") the xUnit Console Runner was included -
so from root we can now run the unit tests via
.\packages\xunit.runner.console\tools\net472\xunit.console.exe .\src\PostSharpAndPaket\bin\Debug\PostSharpAndPaket.dll
Paket commands
-
(re-) install packages after changing
paket.dependencies
file.paket\paket.exe install
-
restoring
package
folder after cleanup DevTree or switching branches.paket\paket.exe restore
comment: 103888639_58799413)
Hint from Daniel Balas (-
Paket throws the warning
Could not detect any platforms from 'unzipper' in '...\packages\PostSharp\build\unzipper\SharpCompress.dll', please tell the package authors
-
to check which versions of PostSharp have this issue the branch
dev/play-with-postsharp-versions
was created (also pushed to remote here) -
indeed the version
5.0.55
doesn't throw this warning -
all later versions (the 6er line) have that issue