سؤال

I had created several configurations on my bundle-project in Visual Studio and I want to define which fragments of code must be included in each configuration. My aim is to get several bootstrappers: some of them will include prerequisites and some will not. I tried something like:

<PackageGroup
       Id="Prerequisites">
      <?if $(Configuration)='Release'?>
      <ExePackage
        Id="Netfx4Client"
        Cache="yes"
        Compressed="yes"
        PerMachine="yes"
        Permanent="yes"
        Vital="yes"
        SourceFile=".\SupportFiles\dotNetFx40_Client_x86_x64.exe"
        DetectCondition="NETFRAMEWORK40CLIENT OR (VersionNT64 AND NETFRAMEWORK40CLIENTX64)"
        InstallCondition="(v4.0.30319 > NETFRAMEWORK40CLIENT OR NOT NETFRAMEWORK40CLIENT)  OR (VersionNT64 AND v4.0.30319 > NETFRAMEWORK40CLIENTX64 OR NOT NETFRAMEWORK40CLIENTX64)"
        InstallCommand="/q /norestart  /log [TempFolder]\dotnetframework4.log"/>
<?endif?>

But of course it is not correct.. Is it possible to manage which fragments of code will be included into chain of packages of the Bundle depending on any variable? Thank you.

هل كانت مفيدة؟

المحلول

Yes, you first need to pass the MSBuild property to the compiler's preprocessor. In your .wixproj use the DefineConstants property to tunnel the property through. The default .wixproj provided by Votive does this by default for Configuration but for other properties it'd look like this:

<PropertyGroup>
   <DefineConstants>$(DefineConstants);MyNewVariable=$(MSBuildPropertyName)</DefineConstants>
</PropertyGroup>

Now that the MSBuild Property is a preprocessor variable you can do the following:

<?if $(var.Configuration)="Release" ?>
    Stuff to conditionally compile out
<?endif?>

Basically, your example above is correct except you're missing the var. part of the preprocessor variable name. More details on the preprocessor syntax in the documentation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top