MSBuild中的VCBuild任务-更改输出路径 [英] VCBuild task in MSBuild - change outputpath

查看:130
本文介绍了MSBuild中的VCBuild任务-更改输出路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我们的其中一种产品编写自动构建,并且碰壁了一些VC ++项目:我需要能够将输出路径设置为程序集所在的位置复制完成后.

I'm attempting to write an automated build for one of our products, and I've hit up against a wall for some of our VC++ projects: I need to be able to set the output path to where the assemblies will be copied once its done.

这是一个临时的msbuild文件:

Here is a makeshift 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>





Stijn的答案:





Stijn's Answer:

我想我会用这个空间来说明我个人如何使用Stijn的答案来解决这个问题.他的MSBuild文件中有一些代码可以为他编写vsprops文件.我决定采用一种更简单的方法,只需手动写入文件即可.

I thought I'd use this space to clarify how I personally used Stijn's answer to solve this. He has some code in his MSBuild file that writes the vsprops file for him. I decided to take a simpler approach and just write the file manually.

我创建了一个名为build.vsprops的文件(我的输出路径为V:)

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>

然后我编辑了我的MSBuild文件以添加Override参数:

Then I edited my 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>

推荐答案

看一下

have a look at the Override parameter for the VCBuild task. Basically you specify a property sheet which you can use to override whatever property you want (it has the same effect as adding a property sheet to the top of the list in a project within VS). You could even generate the override file using the WriteLinesToFile task.

示例:

<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.

Then pass $(VCOverridesFile) to the Override property and make sure your VCBuild Task DependsOnTarget WriteOverridesFile.

这篇关于MSBuild中的VCBuild任务-更改输出路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆