-
Notifications
You must be signed in to change notification settings - Fork 651
Add WiX define constants #1647
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
Add WiX define constants #1647
Conversation
d734c8d
to
96d68f5
Compare
96d68f5
to
b0ee954
Compare
When a WiX project has been detected via the property WixTargetsImported and GenerateGitVersionWixDefines is true, the GitVersion_* properties are passed to the WiX compiler so that they me be used as $(var.GitVersion_*) in .wxs files. This avoids the need to run the executable version to generate a .wxi file.
b0ee954
to
add68f8
Compare
I think this is a great idea to round up the WiX support. @asbjornu what do you thing about adding this to the 5.0.0 milestone? |
@jbaehr, I have no way to validate that this does anything useful to anyone, so if you vouch for the usefulness of this PR, I suppose we can merge it. :) |
Agree, but we can do the other way around, this one merged is not affecting the other one. I'd prefer this one to merge first till we do the review of the other PR, and do a rebase of the #1677. |
Ok, I just thought #1677 "deserved" to be merged first since it's been lingering for a while, but since there won't be any conflicts, I suppose it's the same. |
Yep. Just let's merge this one and we can continue on the other one. |
Thank you for your contributions, @tpaxatb! 🙏 |
Sweet, thanks for taking this mainline so we don't have to remember to add this manually here. This actually has been very useful for us because you are able to do something like:
And useful if you want to version specific unversioned files to the current version for patching rather than using the hash/date method. Manually updating the .wxs files was a royal pain for sure. The only thing you have to do is either a post build step to rename the file (since the file name property is set before the git version task is run) OR (like us) have the CI system generate the same git version and do the rename on deployment. I will submit changes in the documentation (I was waiting to do so until this was merged) after I get back I will be in China on business for the next week then I go on vacation for another week... |
Please create an issue and assign it on you regarding documentation. Thanks for your time! |
#1681 Opened (Apparently I can't assign to myself though haha) |
This is (would be) an awesome feature but I can't figure out how to make it work. If I do this:
Then I get this:
So it isn't "Plug-n-Play" and I can't find WiX referenced in the docs... what am I missing? (I have installed NuGet package GitVersionTask 5.0.1) |
@NameOfTheDragon, #1681 is still unresolved, so that's why we have no documentation for this. Why it doesn't work, though, @tpaxatb would have to help out with as I don't use Wix myself. Which version of GitVersion are you using, @NameOfTheDragon? |
I'm sorry I haven't had a chance to do anything because of my "real" job haha. @NameOfTheDragon I will need to know your exact version of GitVersionTask, as support for the $(var.GitVersion*) things didn't exist until a later beta of the 5.0 cycle. In addition, there is an issue in Visual Studio 2019 that I am aware of in that if you download a nuget package and attach it to a project, the project doesn't get reloaded and the internal targets for the project aren't updated. The only solution I have found for that is to shut down and restart Visual Studio. I also know that up until fairly recently, the nuget version numbers on the packages would be not sorted correctly, so if you had beta.127 and did a package upgrade, it would think beta.4 would be the update and actually downgrade your package. Ensure you are at 5.0.0 release (I honestly don't recall what label was the first appearance of the parameters but it was anything after mid-may i blieve) and look at the output msbuild command line. If you do not see the command line parameters "-dGitVersion_MajorMinorPatch=x.y.z on the candle command line, you are using a version of GitVersionTask that does not have this feature. This is a "Works For Me" thing until I know more information, as my company utilizes this feature on a daily basis for our product versioning and I know it works with stable 5.0.0 as I literally just tested it to make sure that there wasn't a typo somewhere... |
And this may be a silly question, @NameOfTheDragon but are you sure that you have pulled the GitVersionTask package and it is attached to the WiX project itself? i.e. there's a packages.config in the project folder? Be aware that if you have divided your WiX projects into several sub projects, you will need to attach the GitVersionTask package to any project that is referencing the $(var.GitVersion_*) defines, as the stage that uses these references is the candle (compile) stage. |
Yes, I have pulled 5.0.1 and have done so in the WiX project. Here's the packages.config from that project:
My GitVersion command line is also reporting
But that hasn't made any difference. I've restarted VisualStudio several times since updating the NuGet package so that isn't the reason. |
OK, I'm definitely using package version 5.0.1 (and command line version 5.0.1). I created a new project, and that works. I can see all the -dGitVersion_XXX properties being defined. However in my "real" solution, those properties don't appear. I'm using a few project references and I do get defines for all of those, but nothing for GitVersion. I've compared the two .wixProj files and although there are obviously some differences, I really can't see why one works and the other doesn't. I'm attaching my full |
@NameOfTheDragon: Maybe MSBuild Binary and Structured Log Viewer can help you to track the issue down. |
This worked for me after a bit of effort. I then applied this to my actual project. I made a few mistakes not correcting paths to the package folder which will pass without warning if incorrect. But once they were sorted it worked and it's great. |
Ahhhh. this could very well be the issue. I am using the toolset, not the nuget packages. In other news the define constants section that is in the build subdirectory does NOT exist in the buildMultiTargeting folder. It would help to get your exact solution setup and installation and steps to replicate, because it is not repeatable even when I grab the nuget package and apply it to my wix project file. |
We use WIX on a CI Server, so I keep the toolset off my PC to avoid inadvertently relying on it. I don't know if using the nuget package made any difference.
and my packages.config...
My product.wxs is an out-of-the-box generated V3 one except with the changes at the top...
I did a git init and committed my changes to master, but I got pretty clear errors that I needed to do that. |
Sorry it's taken me a while to get back. When I create a brand new WiX project, it seems to work, but it seems to be pre-existing projects that are having issues, and I can't see why. I have just found a second project that doesn't work. It;s one I haven't worked on for a couple of years but I've updated all my NuGet packages and installed GitVersionTask for the first time in this project. No versioning. This one is open source so I guess you could check it out and try to build it if that would help? It's at https://github.com/Tigra-Astronomy/TA.ArduinoPowerController.AscomServer/tree/feature/embedded-driver (feature/embedded-driver branch) |
I've just converted another project and I noticed that I got the
and
|
@NameOfTheDragon So for now you can either update your WiX-Projects to the newer templates (basically what @SeanWilliamson2004 did), or just set GitVersion's "GetVersion" as InitialTagets of your project. |
When a WiX project has been detected via the property WixTargetsImported
and GenerateGitVersionWixDefines is true, the GitVersion_* properties
are passed to the WiX compiler so that they me be used as
$(var.GitVersion_*) in .wxs files. This avoids the need to run the
executable version to generate a .wxi file.
Now that I can build within Visual Studio...
This adds the GitVersion_* values as defines to WiX projects when using the build task (via the targets). This seems a lot cleaner and "out of the box" than instructing people to do a manual step (either running the executable to generate a .wxi file, or to manually edit the wixproj file).
My question is: the executable, when generating the wxi, was introduced in #1599. However, there is a discrepancy between the defines produced and the defines the Task produces. The task creates the defines as matching the actual MSBuild property (e.g. -dGitVersion_Major=$(GitVersion_Major). The defines generated by the executable, however, do not have these prefixed. I believe they need to be consistent so that people running the executable with the include file can also utilize the same .wxs in a msbuild environment. Personally, I believe that the defines created by the executable via the GitVersionCore/WixVersionFileUpdater.cs should be prefixed with the GitVersion_ string to avoid potential collisions (especially with Major, Minor, and Patch), however, since that has been already merged, I can easily remove the prefix from the targets. Or if someone has a different preferred methodology, I can use that. Regardless, before this PR is merged, the discrepancy should be fixed.
This way the "Using" section of the documentation just needs to state they need to reference $(var.GitVersion_*) whether they use the GitVersionExe generate include .wxi method OR the GitVersionTask method.
Neither PR #1645 nor PR #1634 are affected by this change.