Customising Visual Studios Build

Previously, the way I would hook into a projects/solutions build was to edit the .csproj file to import a build file. It always annoyed me and isn’t immediately clear to people (or me after I come back to a project) how the targets are being injected.

I recently discovered that you can follow certain naming conventions to automagically get your targets imported into the build. Now, I know some people think automagic is even less transparent than explicitly defining something, however the naming is quite straightforward and obvious.

Add a targets file named; [after|before].<SolutionName>.sln.targets to the same directory as your solution file.

The after file is added after the project files and the before file is added before the project files.

This only works for solutions.
As an example

<Target Name="RunPostBuildScripts" AfterTargets="Build">
   <!-- Do Stuff Here -->
</Target>

More Info Here
Advertisements
Tagged

2 thoughts on “Customising Visual Studios Build

  1. […] This example will use TeamCity as the build platform as well as the Alpha Nuget Trigger and Update/Install Packages Build step found here. It will also use my preferred Package Update Strategy defined here. The build targets are specified in the build directory of the solution (here) The build targets are linked into the solutions via the Named MsBuild Hook. […]

  2. If some one wants to be updated with hottest technologies
    then he must be pay a visit this website and be up to date
    everyday.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: