VCBuild's task in MSBuild is to change the output path

I am trying to write an automatic assembly for one of our products, and I came across a wall for some of our VC ++ projects: I need to be able to set the exit path to where the assemblies will be copied after its completion.

Here is the temporary msbuild file:

<Project DefaultTargets="Build"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
         ToolsVersion="3.5">
 <Target Name="Build">
   <VCBuild Projects="C:\src\SomeProject\SomeProject.vcproj"
            ToolPath="C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages"
            Configuration="Debug" />
 </Target>
</Project>





Reply to Stijn:

I thought I would use this space to figure out how I personally used Stijn's answer to solve this problem. It has code in the MSBuild file that writes the vsprops file for it. I decided to use a simpler approach and just write the file manually.

I created this file called build.vsprops (my output path is V :)

<?xml version="1.0"?>
<VisualStudioPropertySheet ProjectType="Visual C++"
                           Version="8.00"
                           Name="Overrides"
                           OutputDirectory="V:\">
  <Tool Name="VCCLCompilerTool"
        AdditionalUsingDirectories="V:\" />
</VisualStudioPropertySheet>

Then I edited the MSBuild file to add the Override parameter:

<Project DefaultTargets="Build"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
         ToolsVersion="3.5">
 <Target Name="Build">
   <VCBuild Projects="C:\src\SomeProject\SomeProject.vcproj"
            ToolPath="C:\Program Files\Microsoft Visual Studio 9.0\VC\vcpackages"
            Configuration="Debug"
            Override="$(MSBuildProjectDirectory)\build.vsprops" />
 </Target>
</Project>
+3
source share
2

VCBuild. , , ( , VS). WriteLinesToFile.

:

<PropertyGroup>
  <VCOverridesFile Condition=" '$(VCOverridesFile)'=='' ">overrides.vsprops</VCOverridesFile>
  <VCOverridesOpen>%3C?xml version=%221.0%22?%3E%0D%0A%3CVisualStudioPropertySheet ProjectType=%22Visual C++%22 Version=%228.00%22 Name=%22My Overrides%22%3E</VCOverridesOpen>
  <VCOverridesClose>%3C/VisualStudioPropertySheet%3E</VCOverridesClose>
  <MyOutPath>&lt;Tool Name="VCLinkerTool" OutputFile ="c:\my.exe"/&gt;</MyOutPath>
</PropertyGroup>

<Target Name="WriteOverridesFile">
  <WriteLinesToFile
    File="$(VCOverridesFile)"
    Lines="$(VCOverridesOpen);$(AdditionalVCOverrides);$(VCOverridesClose)"
    Overwrite="true" />
</Target>

$(VCOverridesFile) Override , VCBuild DependsOnTarget WriteOverridesFile.

+2

, msbuild.

msbuild yourProject /p:OutDir=yourPath

, . , "OutDir" , SomeProject.vcproj

0

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


All Articles