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

[Bug] /updatewixversionfile does not cleanly recreate the file #2257

Closed
tcs-devel opened this issue May 5, 2020 · 4 comments · Fixed by #2259
Closed

[Bug] /updatewixversionfile does not cleanly recreate the file #2257

tcs-devel opened this issue May 5, 2020 · 4 comments · Fixed by #2259
Labels
Milestone

Comments

@tcs-devel
Copy link

tcs-devel commented May 5, 2020

The content of the file GitVersion_WixVersion.wxi is not fully overwritten/recreated when the file already exists and GitVersion /updatewixversionfile is invoked. Instead it just overwrites the first x bytes.

Expected Behavior

The entire content of GitVersion_WixVersion.wxi is overwritten and the file has a valid content afterwards.

Actual Behavior

If the existing file is larger than the newly generated file, parts of the previously existing content remain in the file.

Possible Fix

Delete the file prior writing/correctly write the content.

Steps to Reproduce

  1. Create a large dummy file called GitVersion_WixVersion.wxiin the root of a repo.
  2. Run GitVersion /updatewixversionfile
  3. After that, the file looks like this (shortend the wix related content):
<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define AssemblySemFileVer="2.0.0.0"?>
  <?define AssemblySemVer="2.0.0.0"?>
  ...
  <?define WeightedPreReleaseNumber="30001"?>
</Include>ignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. 

Your Environment

  • Version Used: 5.3.2+Branch.master.Sha.438d45004092e2f6b9aa4d12b07c64becfff4031 (also in 5.2.4)
  • Operating System and version (Windows 10, Ubuntu 18.04): Windows
@tcs-devel tcs-devel added the bug label May 5, 2020
@asbjornu
Copy link
Member

asbjornu commented May 5, 2020

I don't use Wix myself, so I don't know where to start looking to fix this. Would you be up for having a look yourself and possibly submitting a PR, @tcs-devel?

@arturcic
Copy link
Member

arturcic commented May 6, 2020

@tcs-devel at the time we added wix support via #1599 it was not specified how exaclty it should work, but the idea was to update, as we have with assemblyinfo, not to re-create.

You can check the implementation here https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/VersionConverters/WixUpdater/WixVersionFileUpdater.cs#L27-L40. In case the current implementation is not the way you think it should we can discuss

@tcs-devel
Copy link
Author

tcs-devel commented May 6, 2020

@asbjornu: Using wix itself is not required. It can easily be reproduced without wix. Just create a file GitVersion_WixVersion.wxi in the root of a repo which is larger than the file that will be created by calling GitVersion /updatewixversionfile. You will see that afterwards the content of the file GitVersion_WixVersion.wxi starts with the generated content followed by parts of the previous content.

The issue is, that WixVersionFileUpdater uses OpenWrite(...)

using var fs = fileSystem.OpenWrite(wixVersionFile);

see the behavior as documented e.g. in
https://docs.microsoft.com/en-us/dotnet/api/system.io.file.openwrite?view=netcore-3.1

I added some changes in #2259

asbjornu added a commit that referenced this issue May 8, 2020
…eneration

Issue #2257 Ensure Valid Wix Version File
@arturcic arturcic added this to the 5.3.3 milestone May 12, 2020
@github-actions
Copy link

🎉 This issue has been resolved in version 5.3.3 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants