【问题标题】:Error WIX0150: Undefined preprocessor variable when using ProjectReference against a multi-targeted project错误 WIX0150:针对多目标项目使用 ProjectReference 时未定义的预处理器变量
【发布时间】:2023-01-08 10:14:20
【问题描述】:

我有两个项目:ConsoleApp1 和 Package1。两者分别是 net7.0 和 wix4 安装项目的“空”项目模板。 ConsoleApp1 被修改为具有 <TargetFrameworks>net7.0</TargetFrameworks>。从 Package1 添加项目引用并尝试通过预处理器、绑定或其他方式访问来自 ConsoleApp1 的文件是不成功的。

ConsoleApp1.csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFrameworks>net7.0</TargetFrameworks>
  </PropertyGroup>
</Project>

Package1.wixproj

<Project Sdk="WixToolset.Sdk/4.0.0-rc.1">
  <ItemGroup>
    <ProjectReference Include="..\ConsoleApp1\ConsoleApp1.csproj"/>
  </ItemGroup>
</Project>

ExampleComponents.wxs

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <ComponentGroup Id="ExampleComponents" Directory="INSTALLFOLDER">
      <Component>
        <File Source="ExampleComponents.wxs" />
        <File Source="$(var.ConsoleApp1.TargetPath)" KeyPath="yes" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

不起作用的事情:

  • 在wixproj中设置TargetFrameworkTargetFrameworks
  • 在wixproj ProjectReference中使用AdditionalProperties="TargetFramework=net7.0"
  • 在贫瘠的wix4文档页面上哀叹

如果我在控制台项目中使用 &lt;TargetFramework&gt; 而不是 &lt;TargetFrameworks&gt;,错误就会解决 - 但我需要多目标。我如何才能依赖 ProjectReference 使用 wix4 进行多目标项目?

【问题讨论】:

    标签: .net-core msbuild wix wix4


    【解决方案1】:

    使用SetTargetFramework 避免项目引用中的多目标。我不确定为什么 AdditionalProperties 失败但 SetTargetFramework 成功。

    更新了 Package1.wixproj:

    <Project Sdk="WixToolset.Sdk/4.0.0-rc.1">
      <ItemGroup>
        <ProjectReference Include="..ConsoleApp1ConsoleApp1.csproj">
          <SetTargetFramework>TargetFramework=net7.0</SetTargetFramework>
        </ProjectReference>
      </ItemGroup>
    </Project>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      • 2011-01-05
      • 2019-09-19
      • 1970-01-01
      • 2013-08-26
      • 2021-08-07
      • 2012-12-02
      相关资源
      最近更新 更多