After build events can be added to the property page of a visual studio project. You can also add your own “targets” file to the afterbuild (or beforebuild) in the project file itself. Use the following method:
- Add a targets file to your project with the following contents (for example)
[sourcecode language=”html”]
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="WSPBuild"
xmlns=http://schemas.microsoft.com/developer/msbuild/2003>
<PropertyGroup>
<WSPBuilderPath>"….ToolsWSPBuilder.exe"</WSPBuilderPath>
</PropertyGroup>
<Target Name="WSPBuild">
<Exec Command="cd $(ProjectDir)" Outputs="null" />
<Message Text="Executing WSP Builder in directory $(ProjectDir)"/>
<Exec Command="$(WSPBuilderPath) "/>
</Target>
</Project>
[/sourcecode] - Unload the project file
- Right click the project file and choose Edit…..
- Add an import tag below the last import tag in the projectfile:
[sourcecode language=”html”]
<Import Project="wspbuilder.Targets" />
[/sourcecode] - Uncomment the AfterBuild tag and add the following statements; remember to specify the adjust CallTarget!
[sourcecode language=”html”]
<Target Name="AfterBuild">
<CallTarget Targets="BuildSharePointPackage" />
</Target>
[/sourcecode]