Visual Studio 2008: launching a custom build target through the project / solution context menu - no add-in

I have a custom build target in a visual studio 2008 C # project. Is there an easy way to add a context menu item to a project so that a custom assembly object can be executed via ide? The build target is not integrated into the default build process and must be started manually. This step should be simple for all developers and should not force them to run msbuild from the command line.

Any hint for a simple working solution?

Regards, Achim

+4
source share
5 answers

Add a new configuration to the project / solution. Then close the project file and open it for editing in XML. Change the DefaultTargets attribute to "PickBuild" and add the following target to the bottom of the file:

<Target Name="PickBuild"> <CallTarget Targets="Build" Condition=" '$(Configuration)' == 'Debug' "/> <CallTarget Targets="Build" Condition=" '$(Configuration)' == 'Release' "/> <CallTarget Targets="SpecialTarget" Condition=" '$(Configuration)' == 'NewConfiguration' "/> </Target> 

Now, to perform a special task, the developer just needs to switch the configuration in Visual Studio and click build. And, on request, it lives inside the file, so it will work on any other computer.

+3
source

If you do not want an add-on, you can have a VS macro that registers a command (in the context menu of an element in the solution explorer) that starts this build process.

+1
source

You can add another build configuration in addition to Debug and Release, and then modify your project to use the MSBuild conditions and properties to determine if your custom goal should work based on the built configuration. If you define the chain correctly, you should be able to prevent the default operations from being performed in accordance with the steps you require.

To make it easier for all developers, once you have created this special project file, you can export it as a template for use by the rest of the team when creating new projects.

+1
source

Not yet contained inside Visual Studio, I just create .cmd files. Inside this file, you use msbuild.exe to create the project. You can also specify properties and other command line options at the same time. When a developer needs to run the assembly, simply double-click the .cmd file.

0
source

In this blog post, Scott Hanselman describes how to create a button in VS to call "msbuild / m"

http://www.hanselman.com/blog/CategoryView.aspx?category=MSBuild

You can do the same, but instead you can call:

  msbuild /t:YourTarget 

Perhaps you could automate the creation of the button.

0
source

Source: https://habr.com/ru/post/1302841/


All Articles