I am developing a nuget package which will set up the current project to use my company's assembly versioning standard. I've got it doing everything I want (so far) smoothly apart from adding in a custom build step.
Historically this has been done manually by editing the .csproj file directly and adding in a couple of new tags into the xml. These are ...
- Property Group
- Target
It actually adds them in successfully, but i've done it by editing the xml rather than via the EnvDTE object in the $project parameter in install.ps1. But I get a message popping up asking my if I want to discard my changes.
I've added $project.Save()
to my script just before I make the changes and that gets rid of the popup, and I just get the one telling me the project has changed and asking me if I want to reload it. Which is better, but still not quite perfect.
Is there a better way to do this?
You can also use the NuGetPowerTools package written by David Fowler (NuGet lead developer).
Add it as a dependency to your package, then in the install.ps1 script, you can call:
Check out the code at https://github.com/davidfowl/NuGetPowerTools for more info.
Scott Hanselman did this at mix11. His technique was to unload the project (using DTE), modify it using PowerShell, then reload it (using DTE again).
http://channel9.msdn.com/Events/MIX/MIX11/FRM09