如何在MSBuild中获取Windows SDK文件夹? [英] How to get the Windows SDK folder in MSBuild?

查看:91
本文介绍了如何在MSBuild中获取Windows SDK文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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 Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\"

在使用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 Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\" />

        <GenerateBootstrapper ApplicationFile="mySetup.msi" 
            Culture="en-US" 
            ApplicationName="My Application" 
            OutputPath="$(OutDir)\en-US" 
            BootstrapperItems="@(BootstrapperFile)" 
            Path="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\" />
    </Target>
</Project>

推荐答案

您还可以使用

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屋!

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