How to get Visual Studio to execute the MsBuild InitialTargets (or creating a project) when loading a project

Introduction

I am looking for the "run when VS loads the project" extension point. This should also be included in the assembly outside of VS. This means that it should end with msbuild scripts.

MSBuild InitialTargets

Now I find that MSBuild offers an extension point to fulfill the goal before doing any other: <Project InitialTargets="..."/> . This fits perfectly with my need for a console / build server. However, with Visual Studio, I would prefer it if it were (optional) when VS loads the solution. So I checked if this is so: Yes and No. When I import the following project into my *.csproj :

  <Target Name="TestOnStart"> <Warning Text="Hey $(MSBuildProjectName) is being initialised"/> </Target> 

After loading the solution into VS, a warning appears for some projects, but not for all.

Questions

  • How can I get VS to execute InitialTargets on every boot?

Or maybe you can help me answer this question by letting me find a solution on my own :-):

  • How does VS determine whether to run the build or run InitialTargets when the project loads?
    • How can I influence this?

Thanks:)

Adding

I just noticed that if I change one of the csproj project project files from outside, VS will ask me if I want to reload the project. If I choose "reload all projects", it will execute the InitialTargets all projects. Therefore, perhaps this should do something with caching or the like. Thus, solving my problem can lead to VS believing that something in the project has changed (after / before loading the solution).

+7
visual-studio visual-studio-2013 msbuild
source share

No one has answered this question yet.

See similar questions:

4
How do you filter ItemGroup?

or similar:

1104
.gitignore for Visual Studio projects and solutions
815
Difference between build solution, rebuild solution, and clean solution in Visual Studio?
758
What are the different โ€œCreate an actionโ€ settings in the properties of a Visual Studio project and what do they do?
741
How do you format code in Visual Studio?
726
How to add an existing directory tree to a project in Visual Studio?
618
How to rename a project folder from Visual Studio?
613
What do you think lines of code in a Visual Studio solution?
566
How to disable all header headers in Visual Studio
485
How to fire Visual Studio post-build events only for debug builds
235
MSBuild does not copy links (DLL files) when using project dependencies in a solution

All Articles