firegiant / HeatWaveSupport

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

Build variables not set during pre-build and post-build events #44

Closed oold closed 9 months ago

oold commented 1 year ago

HeatWave Version

1.0.1.1

Visual Studio Version

16.11.30

Repro Steps

  1. Create new project.
  2. Modify WiX project file to look like this:
    <Project Sdk="WixToolset.Sdk/4.0.0">
    <PropertyGroup>
    <PreBuildEvent>echo $(ProjectDir)</PreBuildEvent>
    <PostBuildEvent>echo $(ProjectDir)</PostBuildEvent>
    </PropertyGroup>
    </Project>
  3. Build the project.

Previously reported and closed in #6. As noted, the issue still occurs.

Actual Result

Output:

ECHO is on.

Expected Result

Output:

C:\solution_dir\project_dir
chrpai commented 10 months ago

Is this going to be fixed in Heatwave? For VS SDK projects VS authors a PostBuild target with an Exec. However Heatwave is authoring a PostBuildEvent property and it's not formatting MSBuild variables correctly.

FireGiantHelp commented 9 months ago

We can reproduce this internally. We expect this issue to be fixed in the next HeatWave release.

duncangroenewald commented 9 months ago

@FireGiantHelp is there a timeframe for the next release. This issue is a bit of a show stopper right now. Thanks.

FireGiantHelp commented 9 months ago

You can apply the fix by hand now. Open the .wixproj, remove the PreBuildEvent property, and add a PreBuild target:

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
  <Exec Command="echo $(ProjectDir)" />
</Target>

HeatWave will do the same when we publish the next release based on our customers' needs.

duncangroenewald commented 9 months ago

@FireGiantHelp Ok thanks I will try that. If I need to perform multiple commands do I need to create multiple lines or should they be included as a single command with multiple lines.

duncangroenewald commented 9 months ago

@FireGiantHelp your suggestion doesn't seem to work. Can you confirm the examples below were what you suggested should be used to fix the issue ? Thanks

This does not seem to work - it complains about Target being undefined

<Project Sdk="WixToolset.Sdk/4.0.3">
  <PropertyGroup>
    <Target Name="PostBuild" BeforeTargets="PostBuildEvent">
        <Exec Command="echo $(ProjectDir)" />
        <Exec Command="echo $(BuiltOuputPath)" />
        <Exec Command="set version=1.2.189" />
        <Exec Command="xcopy $(BuiltOuputPath) $(ProjectDir)Deployment\" />
        <Exec Command="del $(ProjectDir)Deployment\XXXInstallerv%version%.msi" />
        <Exec Command="rename $(ProjectDir)Deployment\XXXInstaller.msi XXXInstallerv%version%.msi" />
        <Exec Command="$(ProjectDir)signer.bat $(ProjectDir)Deployment\" />
    </Target>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="WixToolset.Util.wixext" Version="4.0.3" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\XXX\XXX.csproj" />
  </ItemGroup>
</Project>

Moving Target outside of the PropertyGroup appears to run the commands now but the variables are still undefined

<Project Sdk="WixToolset.Sdk/4.0.3">
  <PropertyGroup>
  </PropertyGroup>
    <Target Name="PostBuild" BeforeTargets="PostBuildEvent">
        <Exec Command="echo $(ProjectDir)" />
        <Exec Command="echo $(BuiltOuputPath)" />
        <Exec Command="set version=1.2.189" />
        <Exec Command="xcopy $(BuiltOuputPath) $(ProjectDir)Deployment\" />
        <Exec Command="del $(ProjectDir)Deployment\XXXInstallerv%version%.msi" />
        <Exec Command="rename $(ProjectDir)Deployment\XXXInstaller.msi XXXInstallerv%version%.msi" />
        <Exec Command="$(ProjectDir)signer.bat $(ProjectDir)Deployment\" />
    </Target>

  <ItemGroup>
    <PackageReference Include="WixToolset.Util.wixext" Version="4.0.3" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\XXX\XXX.csproj" />
  </ItemGroup>
</Project>
firegiantco commented 9 months ago

Your first Target definition is incorrect MSBuild syntax. A Target does not go inside a PropertyGroup.

Your second attempt should probably use AfterTargets="PostBuildEvent" instead of BeforeTargets=....

duncangroenewald commented 9 months ago

Thanks I will try that

duncangroenewald commented 9 months ago

Ok this seems to be working now. However is there any way to get the version number from the main assembly - or any way to define a variable and pass that along. With the usual post build events you can define environment variables such as the example shown below 'variable'

 <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="echo ProjectDir: $(ProjectDir)" />
    <Exec Command="echo TargetPath: $(TargetPath)" />
    <Exec Command="set version=1.2.189" />
    <Exec Command="echo version: %version%" />
  </Target>
FireGiantHelp commented 9 months ago

We'll go ahead and close this case out now, as I believe we have addressed the issue at hand as it relates to HeatWave. At this point, your questions relate to MSBuild itself and the Microsoft common targets.