使用相同的vdproj文件创建x86和x64安装程序?

时间:2009-05-25 09:47:02

标签: visual-studio-2008 deployment x86 64-bit

我想使用相同的Visual Studio 2008部署项目构建x86 msi软件包以及x64软件包。

我在项目属性对话框中看到了一个TargetPlatform,我知道我可以使用它来选择x86或x64(或Itanium)。

问题是我似乎无法将此属性与项目配置(?)

相关联

理想情况下,我希望能够通过从构建脚本(批处理文件)执行两次devenv.exe来创建单独的x86和x64 msi安装程序,每次调用都通过提供参数来设置TargetPlatform属性。

如果可能,我希望避免使用WIX或其他第三方工具。

注意:我注意到x86和x64部署项目之间的差异主要是:

  • Folder \ DefaultLocation = ProgramFilesFolder(x86)| ProgramFiles64Folder(x64)
  • Product \ TargetPlatform =“3:0”(x86)| “3:1”(x64)| “3:2”​​(安腾)

我是否真的必须创建两个单独的部署项目才能使用devenv.exe创建单独的msi包,这只是因为这两个差异?

我想我可以在每次调用devenv.exe之前使用脚本进行这些更改(?)

1 个答案:

答案 0 :(得分:2)

当我遇到这个问题时,我必须在执行devenv命令之前在vdproj文件中使用字符串替换。对于替换我使用SDCTasks的文件替换任务 然后我的msbuild项目看起来几乎像这样:

<Project DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<x86>3:0</x86>
<x64>3:1</x64>
<Import Project="$(SDCTasksPath)\Microsoft.Sdc.Common.tasks"/>
<Target Name="Default">
    <File.Replace Path="$(SolutionDirectory)Setup\Setup.vdproj" OldValue="%22TargetPlatform%22 = %22$(x86)%22" NewValue="%22TargetPlatform%22 = %22$(x64)%22" />
<Exec Command="devenv.exe $(SolutionDirectory)Solution.sln /build $(Configuration) /project $(SolutionDirectory)Setup\Setup.vdproj /projectconfig $(Configuration)"></Exec>