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] GitVersion.MSBuild broken for WiX setup projects #2595

Closed
NameOfTheDragon opened this issue Feb 12, 2021 · 4 comments · Fixed by #3474
Closed

[Bug] GitVersion.MSBuild broken for WiX setup projects #2595

NameOfTheDragon opened this issue Feb 12, 2021 · 4 comments · Fixed by #3474
Assignees
Labels
Milestone

Comments

@NameOfTheDragon
Copy link

NameOfTheDragon commented Feb 12, 2021

Describe the bug
I have previously used GitVersion.Task nuget package in my Wix Toolset setup builds.
After migrating to GitVersion.MSBuild, this no longer works.
The problems seem to be centred around the handling of the Language parameter to the GetVersion task.
Build fails with the following error message:

------ Rebuild All started: Project: TA.NexDome.Bootstrapper, Configuration: Release x86 ------
		"D:\VS-Projects\TA.NexDome.AscomServer\packages\GitVersion.MsBuild.5.6.6\tools\net48/gitversion.exe" "D:\VS-Projects\TA.NexDome.AscomServer\TA.NexDome.Bootstrapper" -output file -outputfile gitversion.json
		D:\VS-Projects\TA.NexDome.AscomServer\packages\WiX.3.11.2\build\..\tools\candle.exe -wx -dGitVersion_UncommittedChanges=0 -dGitVersion_CommitsSinceVersionSourcePadded=0055 -dGitVersion_CommitsSinceVersionSource=55 -dGitVersion_VersionSourceSha=c8e057a899e84b13c4374fa53c87d351b33e7608 -dGitVersion_CommitDate=2021-01-08 -dGitVersion_NuGetPreReleaseTag=beta0105 -dGitVersion_NuGetPreReleaseTagV2=beta0105 -dGitVersion_NuGetVersion=4.0.0-beta0105 -dGitVersion_NuGetVersionV2=4.0.0-beta0105 -dGitVersion_ShortSha=730ef67 -dGitVersion_Sha=730ef678c48a1a00ee8be97122c1d7be2f5268e5 -dGitVersion_EscapedBranchName=release-4-0-0 -dGitVersion_BranchName=release/4.0.0 -dGitVersion_InformationalVersion=4.0.0-beta.105+Branch.release-4.0.0.Sha.730ef678c48a1a00ee8be97122c1d7be2f5268e5 -dGitVersion_FullSemVer=4.0.0-beta.105 -dGitVersion_AssemblySemFileVer=4.0.0.0 -dGitVersion_AssemblySemVer=4.0.0.105 -dGitVersion_LegacySemVerPadded=4.0.0-beta0105 -dGitVersion_LegacySemVer=4.0.0-beta105 -dGitVersion_SemVer=4.0.0-beta.105 -dGitVersion_MajorMinorPatch=4.0.0 -dGitVersion_FullBuildMetaData=Branch.release-4.0.0.Sha.730ef678c48a1a00ee8be97122c1d7be2f5268e5 -dGitVersion_WeightedPreReleaseNumber=30105 -dGitVersion_PreReleaseNumber=105 -dGitVersion_PreReleaseLabelWithDash= -dGitVersion_PreReleaseLabel=beta -dGitVersion_PreReleaseTagWithDash=-beta.105 -dGitVersion_PreReleaseTag=beta.105 -dGitVersion_Patch=0 -dGitVersion_Minor=0 -dGitVersion_Major=4 -dDevEnvDir=F:\VS2019-Preview\Common7\IDE\ -dSolutionDir=D:\VS-Projects\TA.NexDome.AscomServer\ -dSolutionExt=.sln -dSolutionFileName=TA.NexDome.AscomServer.sln -dSolutionName=TA.NexDome.AscomServer -dSolutionPath=D:\VS-Projects\TA.NexDome.AscomServer\TA.NexDome.AscomServer.sln -dConfiguration=Release -dOutDir=..\BuildOutput\ -dPlatform=x86 -dProjectDir=D:\VS-Projects\TA.NexDome.AscomServer\TA.NexDome.Bootstrapper\ -dProjectExt=.wixproj -dProjectFileName=TA.NexDome.Bootstrapper.wixproj -dProjectName=TA.NexDome.Bootstrapper -dProjectPath=D:\VS-Projects\TA.NexDome.AscomServer\TA.NexDome.Bootstrapper\TA.NexDome.Bootstrapper.wixproj -dTargetDir=D:\VS-Projects\TA.NexDome.AscomServer\BuildOutput\ -dTargetExt=.exe -dTargetFileName=NexDomeControlSystem.exe -dTargetName=NexDomeControlSystem -dTargetPath=D:\VS-Projects\TA.NexDome.AscomServer\BuildOutput\NexDomeControlSystem.exe -out obj\Release\ -arch x86 -ext D:\VS-Projects\TA.NexDome.AscomServer\packages\WiX.3.11.2\build\..\tools\\WixNetFxExtension.dll -ext D:\VS-Projects\TA.NexDome.AscomServer\packages\WiX.3.11.2\build\..\tools\\WixUtilExtension.dll -ext D:\VS-Projects\TA.NexDome.AscomServer\packages\WiX.3.11.2\build\..\tools\\WixBalExtension.dll ArduinoDriverInstallerPayload.wxs AscomPlatformBootstrapper.wxs Bundle.wxs NetFx48Bootstrapper.wxs NexDomeAscomServer.wxs NetFx472Bootstrapper.wxs obj\Release\GitVersionInformation.g.cs
candle.exe(0,0): error CNDL0103: The system cannot find the file 'obj\Release\GitVersionInformation.g.cs' with type 'Source'.
Done building project "TA.NexDome.Bootstrapper.wixproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

The error is in the line that invokes candle.exe. All of the version properties are being correctly supplied (example: -dGitVersion_InformationalVersion=4.0.0-beta.105+Branch.release-4.0.0.Sha.730ef678c48a1a00ee8be97122c1d7be2f5268e5 but then right at the end of the line, the file obj\Release\GitVersionInformation.g.cs is being 'injected' into the build. This file does not exist and is not part of the project.. This is clearly not correct for a wix setup project.

I believe this is happening because Language defaults to "C#" and GitVersion is therefore attempting to inject version metadata into the assembly being built. This clearly will not work for a Wix project, since no assembly is being built and there is no compile step being executed.

I have tried:

  • Setting Language to something other than C#, such as "wix". This results in an "Invalid language detected" build error.
  • Setting Language to empty string, results in error: "GenerateGitVersionInformation" task was not given a value for the required parameter "Language".
  • Setting property <UpdateAssemblyInfo>False</UpdateAssemblyInfo> in the .wixproj (no effect)

Expected Behavior

This build should succeed and GitVersion should not try to inject any files into the build process.

Actual Behavior

GitVersion is incorrectly assuming that this is a C# project and is attempting to inject C# code into the build.

Possible Fix

It seems like a very C#-oriented mindset has led to some bad assumptions around how language-specific processing is handled.

This causes problems under Linux because Language is a commonly defined environment variable which gets picked up by the build (issue #2591).

It causes problems in projects that don't have a normal "compile" step, such as Wix setup projects.
It will likely cause problems in other less common project types such as NDoc documentation projects.

It seems to me that what is missing is the recognition that GitVersion may be used from languages that it knows nothing about,
such as Wix, or NDoc, or from completely hand-crafted MSBuild project files that don't use the standard .NET build pipeline.

Consider this code in FileHelper.cs:

        public static string GetFileExtension(string language)
        {
            return language switch
            {
                "C#" => "cs",
                "F#" => "fs",
                "VB" => "vb",
                _ => throw new ArgumentException($"Unknown language detected: '{language}'")
            };
        }

What should I set Language to in a wix project? There is no valid value!!

My suggestion would be to introduce a value of "none" or "other" which explicitly disables language specific processing, and make that the default. In fact, rather than throwing an error and failing the build for an unrecognized language, just disable language-specific processing and perhaps print a warning explaining to the user how to modify their project file to explicitly set Language to an appropriate value.

  • If Language is set to a supported language, then do the appropriate language-specific processing.
  • If Language is set to None then disable any language-specific processing.
  • If Language is set to an unrecognized value, print a warning advising the user to set it to None and continue as if it had been set to None
  • If Language has no value, default to None and continue.
  • Never fail the build because the value of Language is not recognized.

There is no sense in defaulting to "C#" unless you know for sure you are in a C# project. That clearly doesn't work.

Steps to Reproduce

Assumption: Wix Toolset is installed and working in Visual Studio.

  1. File -> New Project. Select "Wix Setup Project for Wix 3.5".
  2. Fill in required parameters in Product.wxs and build. Verify build successful.
  3. Install GitVersion.MSBuild via nuget package manager
  4. Rebuild. Observe build failure.

Here is a ready-made failing minimal project: https://github.com/NameOfTheDragon/GitVersion.Issue

Context

So far, GitVersion.MSBuild has caused problems at every stage of my solution.
I'm still unable to release my build while I rely on GitVersion.
It's a complete showstopper.

Your Environment

https://github.com/NameOfTheDragon/GitVersion.Issue

@Evangelink
Copy link
Contributor

I am facing the same issue and although the linked issue mention some workaround, I am failing to understand what needs to be done. May I have some help?

@Servox3
Copy link

Servox3 commented May 28, 2021

I am not sure if this helps, but for my WiX project, I had to add this to the .wixproj file to be able to build:

<PropertyGroup>
    <UpdateAssemblyInfo>false</UpdateAssemblyInfo>
    <GenerateGitVersionInformation>false</GenerateGitVersionInformation>
</PropertyGroup>

The GitVersion_* properties (like GitVersion_SemVer and GitVersion_AssemblySemFileVer) are still being set, and can be referenced from within the the .wixproj file, like $(GitVersion_SemVer). They are also passed as constants to WiX, like $(var.GitVersion_SemVer).

The .msi file, though, will not have its own AssemblyVersion properties set. I don't know how that can be done.

@github-actions
Copy link

github-actions bot commented Apr 7, 2023

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Apr 7, 2023
@arturcic arturcic removed the stale label Apr 7, 2023
@arturcic arturcic self-assigned this Apr 7, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 10, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 10, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 10, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 11, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 11, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 11, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 12, 2023
arturcic added a commit that referenced this issue Apr 13, 2023
Generate AssemblyInfo and GitVersionInformation files only for c#, f# and vb projects.
@arturcic arturcic added this to the 6.x milestone Apr 13, 2023
@arturcic arturcic modified the milestones: 6.x, 6.0.0-beta.3 Jun 26, 2023
@arturcic
Copy link
Member

🎉 This issue has been resolved in version 6.0.0-beta.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
4 participants