如何在 MSBuild 中获取 Windows SDK 文件夹? [英] How to get the Windows SDK folder in MSBuild?
问题描述
在 MSBuild 任务中检索 Windows SDK 文件夹的方法是什么?
What would be the way to retrieve the Windows SDK folder in an MSBuild task?
使用 generateBootstrapper 任务,我正在为我的设置创建一个引导程序,以便能够安装先决条件.此任务需要先决条件包所在文件夹的路径,即 Windows SDK 文件夹
Using the generateBootstrapper task I'm creating a bootstrapper for my setup to be able to install the pre-requisites. This task needs the path to the folder where the pre-requisite packages are located, i.e. the Windows SDK folder
"C:Program FilesMicrosoft SDKsWindowsv6.0ABootstrapperPackages"
在使用 Visual Studio 2008 时.到目前为止,我一直在使用硬编码路径,但这不适用于任何系统.有没有更好的获取路径的方法?
when using Visual Studio 2008. So far I have been using a hard-coded path but this won't work on any system. Is there a better way to get the path?
这是我的构建脚本:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="3.5">
<ItemGroup>
<BootstrapperFile Include="Microsoft.Net.Framework.2.0">
<ProductName>.NET Framework 2.0</ProductName>
</BootstrapperFile>
<BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
<ProductName>Windows Installer 3.1</ProductName>
</BootstrapperFile>
</ItemGroup>
<Target Name="Bootstrapper">
<GenerateBootstrapper ApplicationFile="mySetup.msi"
Culture="de-DE"
ApplicationName="My Application"
OutputPath="$(OutDir)de-DE"
BootstrapperItems="@(BootstrapperFile)"
Path="C:Program FilesMicrosoft SDKsWindowsv6.0ABootstrapperPackages" />
<GenerateBootstrapper ApplicationFile="mySetup.msi"
Culture="en-US"
ApplicationName="My Application"
OutputPath="$(OutDir)en-US"
BootstrapperItems="@(BootstrapperFile)"
Path="C:Program FilesMicrosoft SDKsWindowsv6.0ABootstrapperPackages" />
</Target>
</Project>
推荐答案
您也可以使用 GetFrameworkSdkPath MSBuild 任务.
You can also use the GetFrameworkSdkPath MSBuild task.
<GetFrameworkSdkPath>
<Output TaskParameter="Path" PropertyName="WindowsSdkPath" />
</GetFrameworkSdkPath>
例如:
<GenerateBootstrapper
ApplicationFile="$(SolutionName).application"
ApplicationName="$(ClickOnceAppTitle)"
ApplicationUrl="$(ClickOnceUrl)"
BootstrapperItems="@(BootstrapperFile)"
Culture="en"
FallbackCulture="en-US"
Path="$(WindowsSDKPath)"
OutputPath="." />
这篇关于如何在 MSBuild 中获取 Windows SDK 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!