c# - 这个 .wixproj 文件的 $(WixTargetsPath) 属性在哪里设置?

标签 c# visual-studio msbuild wix projects-and-solutions

我是项目文件的新手,今天进行了一些调查,以尝试理解使用 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/

相关文章:

c# - FileHelpers:读取文件时如何处理引用的字段

c# - 如何在 visual studio、C# 项目的部署中包含文件和文件夹?

C#:函数求值顺序(相对于 C)

c# - 无法删除表 dbo.Images,因为它不存在或您没有权限

msbuild - 错误: Building Windows Phone application using MSBuild 64 bit is not supported

c# - 线程休眠函数无响应

c# - 编译错误 : Ticks must be between DateTime. MinValue.Ticks 和 DateTime.MaxValue.Ticks。参数名称:ticks

visual-studio - Visual Studio 的轻量级版本

msbuild - NAnt + MSBuild (4.0) == MSBuild 启动失败 w/directory not found 错误

c++ - 使用 MSBuild 目标文件时查看 VS C++ 项目中的有效属性?