Question

Quel serait le moyen de récupérer le dossier Windows SDK dans une tâche MSBuild?

À l'aide de la tâche generateBootstrapper, je crée un programme d'amorçage pour que mon installation puisse installer les conditions préalables. Cette tâche nécessite le chemin d'accès au dossier contenant les packages prérequis, c.-à-d. Le dossier Windows SDK

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

lors de l'utilisation de Visual Studio 2008. Jusqu'à présent, j'utilisais un chemin codé en dur, mais cela ne fonctionnerait sur aucun système. Y a-t-il un meilleur moyen d’obtenir le chemin?

Ceci est mon script de construction:

<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>
Était-ce utile?

La solution

Vous pouvez également utiliser la GetFrameworkSdkPath tâche MSBuild.

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

Par exemple:

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

Autres conseils

merci John. Selon votre message, j'ai édité le script MSBuild pour lire le dossier dans le registre. Il n’était cependant pas nécessaire d’ajouter "Packages". à la fin, c’était une autre erreur dans mon script original.

Voici le script de travail:

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

Le chemin d'installation du Kit de développement logiciel (SDK) Windows est stocké dans la valeur CurrentInstallFolder de la clé de registre suivante:

HKEY_LOCAL_MACHINE \ LOGICIEL \ Microsoft \ Microsoft SDK \ Windows

HKEY_LOCAL_MACHINE \ LOGICIEL \ Microsoft \ SDK \ Windows CurrentInstallFolder

J'ai suivi la réponse de Jeremy D, mais cela a donné le message d'erreur:     erreur MSB3147: Impossible de trouver le fichier requis 'setup.bin' dans 'C: \ Fichiers de programme (x86) \ SDK Microsoft \ Windows \ v8.0A \ Engine'.

La raison en est que le chemin d'accès au démarrage (du moins avec la version 8.0A du SDK) est un sous-répertoire du chemin renvoyé par GetFrameworkSdKPath.

Le code MSBuild qui fonctionne pour moi est donc:

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

Notez le suffixe \ Bootstrapper à $ (WindowsSdkPath)

Le chemin d'accès au programme d'amorçage est stocké sous la clé de registre:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\GenericBootstrapper\3.5

Pour connaître le dossier des packages, ouvrez-le, lisez le "Chemin". valeur de registre et ajoutez " Packages " à la fin et cela devrait vous donner le chemin complet du dossier que vous voulez.

Par exemple:

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);
   }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top