Getting the target task before anything else starts when creating from Visual Studio

I am trying to get a one-time expensive goal to run only when creating a specific top-level project (which has many dependencies).

I have no problem getting this to work from a simple msbuild / command line build. I do this with customization and InitialTargets in a project or, alternatively, with

<BeforeBuild.jpg / p>

The tricky part is with Visual Studio. When I create the same project from VS. VS launches dependencies before even calling my .csproj, so my goal (which affects how other projects are built) does not start until they are already built.

Is there any way to get VS to complete the task before calling the dependencies?

I am currently working on this by launching the same costly goal from my lowest level project (one that is always under construction ...) using:

Condition = "$ (BuildingInsideVisualStudio)"

Any ideas on how to do this “right”? Again, I am looking for a solution that will work from VS.

+3
source share
3 answers

The only way to do this (if I understand the question) is to create a dummy project that you will first tell VS to do whatever you want. VS will accept almost any MSBuild file if you give it the .csproj extension and the build target.

+3
source

Visual Studio proc UX . , VS MSBuild. UseHostCompilerIfAvailable false . VS MSBuild . Visual Studio.

.csproj( .vbproj) follwing.

<PropertyGroup>
    <UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
</PropertyGroup>
+2

<Target Name="BeforeBuild" />? ( Build BeforeBuild). Visual Studio ( ), .csproj .

If you do not want to do something even earlier than in msbuild?

+1
source

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


All Articles