Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building via MSBuild task requires building twice (references are not restored correctly) #7614

Closed
jmairboeck opened this issue Jul 13, 2023 · 4 comments
Labels

Comments

@jmairboeck
Copy link

jmairboeck commented Jul 13, 2023

  • Which version of WiX are you building with?

4.0.1

  • Which version of Visual Studio are you building with (if any)?

MSBuild version 17.6.3+07e294721 for .NET Framework

  • Which version of the WiX Toolset Visual Studio Extension are you building with (if any)?

N/A (Building in Visual Studio works because Dependencies are restored implicitly)

  • Which version of .NET are you building with?

.NET Framework 4.8

  • If the problem occurs when installing your packages built with WiX, what is the version of Windows the package is running on?

N/A

  • Describe the problem and the steps to reproduce it.

We build our Setup projects by calling the MSBuild task from a "master" MSBuild file. The Build target is defined like this:

  <!-- alternative A: -->
  <Target Name="BuildSetup">
    <MSBuild
      Projects="@(SetupProjects)"
      Targets="Restore;Build"
      Properties="$(SetupProperties)"/>
  </Target>

  <!-- alternative B: -->
  <Target Name="BuildSetup">
    <MSBuild
      Projects="@(SetupProjects)"
      Targets="Restore"
      Properties="$(SetupProperties)"/>
    <MSBuild
      Projects="@(SetupProjects)"
      Targets="Build"
      Properties="$(SetupProperties)"/>
  </Target>

Neither of these two alternatives works on the first try. The whole build has to be started a second time for it to succeed. In the first build, WiX extensions and Heat are not included, causing the build to fail.

What is especially weird is that two separate builds with "Restore" first and then "Build" DO work (e.g. by commenting out one of the two MSBuild calls each time in alternative B).

@(SetupProjects) contains a wixlib with harvesting (using the workaround from #3496) and an MSI package. The errors occur during linking the package because of missing references from the extensions, but neither of the two projects include the extensions (or the harvesting part) during the first build.

  • Describe the behavior you expected and how it differed from the actual behavior.

Building via MSBuild should work immediately from a clean working directory.

@barnson
Copy link
Member

barnson commented Jul 13, 2023

Please attach binlogs of failed and successful builds.

@jmairboeck
Copy link
Author

jmairboeck commented Jul 13, 2023

binlogs.zip

failed.binlog was produced without bin and obj folders on both setup projects.

worked.binlog is the same command just run a second time.

restore-only.binlog is again with cleared bin and obj folders and the Build call commented out.

build-only.binlog is with Restore commented out (after restore-only).

@barnson
Copy link
Member

barnson commented Jul 25, 2023

Running Restore as a target in the same invocation as the build isn't supported. That's why MSBuild -Restore was added.

@barnson barnson closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2023
@barnson barnson added msbuild and removed triage labels Jul 25, 2023
@jmairboeck
Copy link
Author

Thank you.

We are now using a separate Restore target in our master build file that calls the MSBuild task with the Restore target on the setup projects and use the -Restore flag when calling MSBuild in CI.

This is needed because the MSBuild task doesn't support that flag yet (see dotnet/msbuild#2811).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants