Skip to content

Commit

Permalink
Merge pull request #1125 from vitezslav-popovsky-solarwinds/assembly-…
Browse files Browse the repository at this point in the history
…version-native

Introduce `NBGV_UseAssemblyVersionInNativeVersion` msbuild property
  • Loading branch information
AArnott authored Dec 9, 2024
2 parents bf4fa8a + 1283c6b commit 36a4796
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/msbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Property | Default | Description
`NBGV_ThisAssemblyNamespace` | (empty) | Sets the namespace to use for the generated `ThisAssembly` class.
`NBGV_EmitThisAssemblyClass` | `true` | When `false`, suppresses generation of the `ThisAssembly` class.
`NBGV_ThisAssemblyIncludesPackageVersion` | `false` | When `true`, a `NuGetPackageVersion` property is added to the `ThisAssembly` class.
`NBGV_UseAssemblyVersionInNativeVersion` | `true` | When `false`, uses the `AssemblyFileVersion` as a native `PRODUCTVERSION`.

### Custom `ThisAssembly` static fields and constants

Expand Down
4 changes: 3 additions & 1 deletion src/Nerdbank.GitVersioning.Tasks/NativeVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ BLOCK NBGV_VERSION_BLOCK

public string TargetFileName { get; set; }

public bool UseAssemblyVersionInNativeVersion { get; set; } = true;

/// <inheritdoc/>
public override bool Execute()
{
Expand Down Expand Up @@ -166,7 +168,7 @@ private void CreateDefines()
return;
}

if (!Version.TryParse(this.AssemblyVersion, out Version productVersion))
if (!Version.TryParse(this.AssemblyVersion, out Version productVersion) || !this.UseAssemblyVersionInNativeVersion)
{
productVersion = fileVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
AssemblyLanguage="$(AssemblyLanguage)"
AssemblyCodepage="$(AssemblyCodepage)"
TargetFileName="$(TargetFileName)"
UseAssemblyVersionInNativeVersion="$(NBGV_UseAssemblyVersionInNativeVersion)"
/>
<!-- Avoid applying the newly generated Version.rc file to the build
unless it has changed in order to allow for incremental building. -->
Expand Down

0 comments on commit 36a4796

Please sign in to comment.