我是项目文件的新手,今天进行了一些调查,以尝试理解使用 VS2019 WiX 项目模板自动生成的 .wixproj 文件。我能够理解大部分内容,但我被困在一个小问题上。 $(WixTargetsPath) 属性在哪里设置?此时我可能已经浪费了很多时间无缘无故地试图解决这个问题,但我现在很好奇!我阅读了在 proj 文件中设置属性的所有不同方式,但我无法在任何地方找到变量定义。这是我的 .wixproj 文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>TestGUID-1234</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>MySetup</OutputName>
<OutputType>Package</OutputType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="MainComponents.wxs" />
<Compile Include="Product.wxs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyOtherProj\MyOtherProj.csproj">
<Name>MyOtherProj</Name>
<Project>TestGUID-1234/Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
<Name>WixUIExtension</Name>
</WixExtension>
<WixExtension Include="WixNetFxExtension">
<HintPath>$(WixExtDir)\WixNetFxExtension.dll</HintPath>
<Name>WixNetFxExtension</Name>
</WixExtension>
</ItemGroup>
<ItemGroup>
<Content Include="TestLicense.rtf" />
</ItemGroup>
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixTargetsImported)' != 'true' ">
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
</Target>
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
</Project>
我检查了环境变量,但没有找到任何东西。我阅读了 .props 文件,但不知道 wix.props 文件将包含在哪里。它是使用 msbuild 构建的,所以我知道它已设置,但除了 wix 安装程序修改 msbuild.exe 以包含其他默认属性外,我不知道该属性的设置位置。
最佳答案
事实并非如此。
Condition=" '$(WixTargetsPath)' != '' "
确保导入
仅在已设置时才尝试。
如果您想指向不在下一行中使用的 MSBuildExtensionsPath32
路径中的 wix.targets 文件,则该行存在。
关于c# - 这个 .wixproj 文件的 $(WixTargetsPath) 属性在哪里设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70074557/