Directory.Build.props version tags not used correctly when multi-target building from VS2017
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 141
Description
When building from Visual Studio 2017 (15.8.5), Directory.Build.props version tags are only used to generate assemblyinfo for first target when multi-targeting frameworks.
When having a project with multiple target frameworks, only the first target output assembly gets the correct version info when built from Visual Studio 2017.
When building from the CLI with MSBuild, this works correctly and as expected.
I'm not sure if this is the right place to post this, if not, I appologize.
**Update:**
With further investigation it seems to get a bit more confusing.
After changing the Directory.Build.props file it fails like described. Restarting Visual Studio fixes it, until the next change to the props file. So it seems to be a caching issue.
I now also see the same issue on our build server, where we use MSBuild, but there I'm not sure what to restart. I will continue to investigate this as a caching issue.
### Steps to reproduce
Create a .NET Core Library project and setup multi-targeting, see project file below.
Create a Directory.Build.props file one level above the project folder, see props file below.
Build using Visual Studio 2017.
Directory.Build.props file
```xml
...
MyProduct
MyCompany
Copyright © 2018
MyDescription
8.8.5.0
8.8.50100.0
Debug Build
Debug Build ($(TargetFramework)), ($(TargetFrameworkIdentifier))
...
```
Project file
```xml
...
Library
net472;netcoreapp2.1
Namespace.MyAssembly
Namespace.MyAssembly
latest
..\bin\$(Configuration)
true
...
```
### Expected behavior
Both output assemblies should have the same version info as specified in the Directory.Build.props file.
### Actual behavior
Only the first output assembly generate for the first target listed in in the project file has the correct assembly version info.
The assemblyinfo.cs in the first target's obj folder is:
```xml
...
[assembly: System.Reflection.AssemblyCompanyAttribute("MyCompany")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © 2018")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("MyDescription")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("8.8.50100.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("Debug Build")]
[assembly: System.Reflection.AssemblyProductAttribute("MyProduct")]
[assembly: System.Reflection.AssemblyTitleAttribute("Debug Build (net472), ()")]
[assembly: System.Reflection.AssemblyVersionAttribute("8.8.5.0")]
...
```
The assemblyinfo.cs in the second target's obj folder is:
```xml
...
[assembly: System.Reflection.AssemblyCompanyAttribute("MyCompany")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © 2018")]
[assembly: System.Reflection.AssemblyDescriptionAttribute("MyDescription")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("4.0.00100.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("Debug Build")]
[assembly: System.Reflection.AssemblyProductAttribute("MyProduct")]
[assembly: System.Reflection.AssemblyTitleAttribute("Debug Build (netcoreapp2.1), ()")]
[assembly: System.Reflection.AssemblyVersionAttribute("4.0.0.0")]
...
```
(Where this 4.0.00100.0 comes from I'm not quite sure, I did use that version at some point during testing.)
Everything works as expected if building from the CLI using MSBuild.
### Environment data
`msbuild /version` output:
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
15.8.169.51996
OS info:
Visual Studio 2017 enterprise: 15.8.5+28010.2036
dotnet --version: 2.1.402
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.