Skip to content

Commit 1283c6b

Browse files
Introduce NBGV_UseAssemblyVersionInNativeVersion msbuild property
1 parent bf4fa8a commit 1283c6b

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

doc/msbuild.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Property | Default | Description
4949
`NBGV_ThisAssemblyNamespace` | (empty) | Sets the namespace to use for the generated `ThisAssembly` class.
5050
`NBGV_EmitThisAssemblyClass` | `true` | When `false`, suppresses generation of the `ThisAssembly` class.
5151
`NBGV_ThisAssemblyIncludesPackageVersion` | `false` | When `true`, a `NuGetPackageVersion` property is added to the `ThisAssembly` class.
52+
`NBGV_UseAssemblyVersionInNativeVersion` | `true` | When `false`, uses the `AssemblyFileVersion` as a native `PRODUCTVERSION`.
5253

5354
### Custom `ThisAssembly` static fields and constants
5455

src/Nerdbank.GitVersioning.Tasks/NativeVersionInfo.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ BLOCK NBGV_VERSION_BLOCK
108108

109109
public string TargetFileName { get; set; }
110110

111+
public bool UseAssemblyVersionInNativeVersion { get; set; } = true;
112+
111113
/// <inheritdoc/>
112114
public override bool Execute()
113115
{
@@ -166,7 +168,7 @@ private void CreateDefines()
166168
return;
167169
}
168170

169-
if (!Version.TryParse(this.AssemblyVersion, out Version productVersion))
171+
if (!Version.TryParse(this.AssemblyVersion, out Version productVersion) || !this.UseAssemblyVersionInNativeVersion)
170172
{
171173
productVersion = fileVersion;
172174
}

src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
AssemblyLanguage="$(AssemblyLanguage)"
216216
AssemblyCodepage="$(AssemblyCodepage)"
217217
TargetFileName="$(TargetFileName)"
218+
UseAssemblyVersionInNativeVersion="$(NBGV_UseAssemblyVersionInNativeVersion)"
218219
/>
219220
<!-- Avoid applying the newly generated Version.rc file to the build
220221
unless it has changed in order to allow for incremental building. -->

0 commit comments

Comments
 (0)