msbuild winapi bootstrapper

¿Cómo obtener la carpeta Windows SDK en MSBuild?



winapi bootstrapper (5)

¿Cuál sería la forma de recuperar la carpeta Windows SDK en una tarea MSBuild?

Usando la tarea generateBootstrapper, estoy creando un bootstrapper para que mi configuración pueda instalar los requisitos previos. Esta tarea necesita la ruta a la carpeta donde se encuentran los paquetes de requisitos previos, es decir, la carpeta SDK de Windows

"C:/Program Files/Microsoft SDKs/Windows/v6.0A/Bootstrapper/Packages/"

cuando uso Visual Studio 2008. Hasta ahora he estado usando una ruta codificada, pero esto no funcionará en ningún sistema. ¿Hay una mejor manera de obtener el camino?

Este es mi script de compilación:

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


La ruta al programa de arranque se almacena bajo la clave de registro:

HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/GenericBootstrapper/3.5

Para averiguar la carpeta de paquetes, ábralo, lea el valor de registro "Ruta" y anexe "Paquetes" al final, que le proporcionará la ruta completa a la carpeta que desea.

Por ejemplo:

string bootStrapperPackagesFolder = ""; RegistryKey regKey = Registry.LocalMachine.OpenSubKey (@"SOFTWARE/Microsoft/GenericBootstrapper/3.5"); if (regKey != null) { bootStrapperPackagesFolder = (string)regKey.GetValue("Path"); if (bootStrapperPackagesFolder != null) { bootStrapperPackagesFolder += @"Packages/"; Console.WriteLine(bootStrapperPackagesFolder); } }


La ruta de instalación del Windows SDK se almacena en el valor CurrentInstallFolder de la siguiente clave de registro:

HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/Windows


Seguí la respuesta de Jeremy D, pero me dio el mensaje de error: error MSB3147: no se pudo encontrar el archivo requerido ''setup.bin'' en ''C: / Archivos de programa (x86) / Microsoft SDKs / Windows / v8.0A / Engine'' .

La razón es que la ruta al programa de arranque (al menos con V8.0A del SDK) es un subdirectorio en la ruta devuelta por GetFrameworkSdKPath.

Entonces, el código MSBuild que funciona para mí es:

<Target Name="AfterBuild"> <GetFrameworkSdkPath> <Output TaskParameter="Path" PropertyName="WindowsSdkPath"/> </GetFrameworkSdkPath> <GenerateBootstrapper ApplicationFile="myapp.msi" ApplicationName="MyApplication" BootstrapperItems="@(BootstrapperFile)" OutputPath="$(OutputPath)" Path="$(WindowsSdkPath)/Bootstrapper" /> </Target>

Tenga en cuenta el sufijo / Bootstrapper en $ (WindowsSdkPath)


También puede usar la tarea GetFrameworkSdkPath MSBuild.

<GetFrameworkSdkPath> <Output TaskParameter="Path" PropertyName="WindowsSdkPath" /> </GetFrameworkSdkPath>

Por ejemplo:

<GenerateBootstrapper ApplicationFile="$(SolutionName).application" ApplicationName="$(ClickOnceAppTitle)" ApplicationUrl="$(ClickOnceUrl)" BootstrapperItems="@(BootstrapperFile)" Culture="en" FallbackCulture="en-US" Path="$(WindowsSDKPath)" OutputPath="." />


gracias John. Según su publicación, edité el script MSBuild para leer la carpeta del registro. Sin embargo, no fue necesario agregar "Paquetes" al final, ese fue otro error en mi script original.

El siguiente es el script de trabajo:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WindowsSDKPath>$(registry:HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/GenericBootstrapper/3.5@Path)</WindowsSDKPath> </PropertyGroup> <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="$(WindowsSDKPath)" /> <GenerateBootstrapper ApplicationFile="mySetup.msi" Culture="en-US" ApplicationName="My Application" OutputPath="$(OutDir)/en-US" BootstrapperItems="@(BootstrapperFile)" Path="$(WindowsSDKPath)" /> </Target> </Project>