Skip to content

Commit 8b09236

Browse files
authored
Merge pull request #2882 from InKahootz/msbuild-wpf-warning
Clarify WPF specific flags and subsequent warning
2 parents 0b94c77 + 604d748 commit 8b09236

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

docs/input/docs/usage/msbuild.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,39 @@ The next thing you need to do is to remove the `Assembly*Version` attributes fro
5151
your `Properties\AssemblyInfo.cs` files. This puts GitVersion.MsBuild in charge of
5252
versioning your assemblies.
5353

54-
DotNet SDK-style projects will generate Assembly Version info along with other
55-
Assembly Info in a 'projectname.AssemblyInfo.cs' file, conflicting with GitVersion.
56-
So, you will need to edit your project. Add [GenerateAssemblyFileVersionAttribute](https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props#generateassemblyfileversionattribute)
57-
under the first PropertyGroup and set it to `false`:
54+
### WPF specific concerns
55+
56+
One futhur step needs to be taken for SDK-style WPF projects.
57+
58+
Building projects with .NET Core SDK with a version lower than v5.0.200
59+
requires turning off automatic generation of the different versioning attributes.
60+
GitVersion usually controls these properties but cannot during WPF specific
61+
targets that generate a temporary project.
5862

5963
```xml
60-
<!-- GitVersion DotNet SDK Compatibility -->
61-
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
64+
<PropertyGroup>
65+
<!-- Wpf workaround: GitVersion and .NET SDK < v5.0.200 -->
66+
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
67+
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
68+
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
69+
</PropertyGroup>
6270
```
6371

72+
For .NET Core SDK v5.0.200 to v6.0.0-preview.1, a opt-in flag was introduced to
73+
allow package references to be imported to the temporary project.
74+
You can now remove the previous versioning attributes and replace them with
75+
a single property.
76+
77+
```xml
78+
<PropertyGroup>
79+
<!-- WPF workaround: GitVersion and .NET SDK between v5.0.200 and v6.0.0-preview.2 -->
80+
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
81+
</PropertyGroup>
82+
```
83+
84+
You can remove all workarounds if you are building with .NET Core SDK
85+
v6.0.0-preview.2 or later as the flag is now opt-out.
86+
6487
### Done!
6588

6689
The setup process is now complete and GitVersion.MsBuild should be working its magic,

src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
-->
5555
<GenerateGitVersionInformation Condition=" '$(GenerateGitVersionInformation)' == '' And '$(_TargetAssemblyProjectName)' != '' ">false</GenerateGitVersionInformation>
5656
<GenerateGitVersionInformation Condition=" '$(GenerateGitVersionInformation)' == '' ">true</GenerateGitVersionInformation>
57+
<!--
58+
Compounding on the previous "GenerateTemporaryTargetAssembly" explanation, "UpdateAssemblyInfo" is
59+
also called in this temp-build. This results in a warning since we already updated assembly info.
60+
Prevent UpdateAssemblyInfo from running a second time.
61+
-->
62+
<UpdateAssemblyInfo Condition=" '$(UpdateAssemblyInfo)' == 'true' And '$(_TargetAssemblyProjectName)' != '' ">false</UpdateAssemblyInfo>
5763

5864
<!-- Property that enables GetVersion -->
5965
<GetVersion Condition=" '$(DisableGitVersionTask)' == 'true' ">false</GetVersion>

0 commit comments

Comments
 (0)