firegiant / HeatWaveSupport

Issues-only repository to report HeatWave bugs and feature requests to FireGiant
3 stars 0 forks source link

ProjectReference with Publish="true" doesn't work in Visual Studio 2022 #18

Closed serhiiz closed 1 year ago

serhiiz commented 1 year ago

HeatWave Version

0.9.4

Visual Studio Version

17.4.4

Repro Steps

When building WiX4 project in Visual Studio which depends on a .NET core project, which in turn needs to be published first, the build fails because the Publish target is not executed, even though the PackageReference has Publish="true".

Steps to reproduce:

  1. In a new solution in Visual Studio create a WPF core app targeting .net7.0-windows. Name it WpfApp1.
  2. Create MSI Package (WiX v4) project. Name it Package1.
  3. Add a Project Reference from the WiX project to WPF project.
  4. Edit Package1.wixproj: Add the following attribute to the ProjectReference tag: Publish="true", like shown below:
<Project Sdk="WixToolset.Sdk/4.0.0-rc.2">
  <ItemGroup>
    <ProjectReference Include="..\WpfApp1\WpfApp1.csproj" Publish="true" />
  </ItemGroup>
</Project>
  1. In the Package1 keep the single file Package.wxs with the content below:
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Package Name="Package1" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="48f71f47-c646-4f82-99dd-fad89a5eb2d6">
    <StandardDirectory Id='ProgramFiles6432Folder'>
      <Directory Id='ApplicationFolder' Name='WpfApp1'>
      </Directory>
    </StandardDirectory>
    <Feature Id="Main">
      <Component Directory='ApplicationFolder'>
        <File Source='WpfApp1.exe' />
      </Component>
    </Feature>
  </Package>
</Wix>
  1. Rebuild the solution in Visual Studio

Actual Result

In Visual Studio the build fails:

Rebuild started...
1>------ Rebuild All started: Project: WpfApp1, Configuration: Debug Any CPU ------
Restored C:\Temp\test2\Package1\Package1.wixproj (in 1 ms).
Restored C:\Temp\test2\WpfApp1\WpfApp1.csproj (in 0.9 ms).
1>WpfApp1 -> C:\Temp\test2\WpfApp1\bin\Debug\net7.0-windows\WpfApp1.dll
2>------ Rebuild All started: Project: Package1, Configuration: Debug x64 ------
2>C:\Temp\test2\Package1\Package.wxs(9): error WIX0103: Cannot find the File file 'WpfApp1.exe'. The following paths were checked: WpfApp1.exe, C:\Temp\test2\Package1\obj\x64\Debug\publish\WpfApp1\WpfApp1.exe
2>Done building project "Package1.wixproj" -- FAILED.
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:00.887 ==========

However, the build succeeds when building using dotnet core toolchain:

PS C:\temp\test2> dotnet build
MSBuild version 17.4.1+9a89d02ff for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  WpfApp1 -> C:\temp\test2\WpfApp1\bin\Debug\net7.0-windows\WpfApp1.dll
  WpfApp1 -> C:\temp\test2\WpfApp1\bin\Debug\net7.0-windows\WpfApp1.dll
  WpfApp1 -> C:\temp\test2\Package1\obj\x64\Debug\publish\WpfApp1\
  Package1 -> C:\temp\test2\Package1\bin\x64\Debug\en-US\Package1.msi

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.81

Also, the build succeeds when building using msbuild:

PS C:\temp\test2> msbuild /t:Restore,Rebuild /p:Configuration=Debug test2.sln
MSBuild version 17.4.1+9a89d02ff for .NET Framework
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 1/23/2023 9:53:24 PM.
...
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.30

If we compare the logs, when build succeeds (dotnet, msbuild), while building Package1 the ResolveProjectReferences target calls WpfApp with "Publish;GetTargetPath" targets. In contrast, when build fails (VS), while building Package1 the ResolveProjectReferences target calls WpfApp with "GetTargetPath" targets (missing Publish).

Expected Result

Build succeeds in Visual Studio.

FireGiantHelp commented 1 year ago

Thank you for the detailed report. We added the issue to our backlog to fix.

FireGiantHelp commented 1 year ago

We expect this issue is fixed in HeatWave v1.0.1 now available in Visual Studio Marketplace so Visual Studio should provide notification of the update.