You need to unload the project before you modify it...
… make modifications and then reloaded it again…
Don’t do this…
You will find the following lines inside any visual studio project…don’t do this. You are better off making minimal changes in the project files. If you write your custom scripts inside seperate files then it's easier to share the msbuild code among your projects.
Organizing your msbuild files
Typically visual studio has reserved the *proj suffix for it’s own files.| c# | csproj |
| visual basic | vbproj |
| c++ | vcproj |
| lightswitch | lsproj |
| vs deployment | vdproj |
| Microsoft.Common.Tasks |
| Microsoft.Common.targets |
| Microsoft.CSharp.targets |
| Microsoft.Data.Entity.targets |
| Microsoft.NETFramework.targets |
| Microsoft.VisualBasic.targets |
| Microsoft.WinFx.targets |
*.Targets files have all the code (msbuild scripts)
Creating custom msbuild files for your VS projects
Create 2 msbuild files with a text editor, or even in visual studio (add new xml file).Example names: My.Tasks & My.Targets
Inside the *.tasks file you reference the necessary tasks
You need to import the *.tasks file insode the targets file
BuildDependsOn PropertGroup
The BuildDependsOn propertgroup overrides the BuildDependsOn of the visual studio build process. You can do here all you need. It’s much better than doing it inside the BeforeBuild and AfterBuild targets of the visual studio project file.
The only thing that is left now is to actually import the msbuild script inside the project file. In the following example I make the assumption that my msbuild scripts reside in the same directory as my solution.
Usefull property groups
Take a look at your project properties –> build events for nice examples of property groups that are already defined in the default build process.
0 comments:
Post a Comment
Post a comment