diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj
index 1c1125b40ced..6bc20fa261a0 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj
@@ -90,6 +90,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.DefaultAssemblyInfo.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.DefaultAssemblyInfo.targets
new file mode 100644
index 000000000000..f65c9ed90944
--- /dev/null
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.DefaultAssemblyInfo.targets
@@ -0,0 +1,31 @@
+
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+
+
+ 1.0.0
+ $(VersionPrefix)-$(VersionSuffix)
+ $(VersionPrefix)
+
+
+
+ $(AssemblyName)
+ $(Authors)
+ $(AssemblyName)
+ $(AssemblyName)
+
+
+
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets
index 67ccc143eba0..25bf6caf3843 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets
@@ -15,6 +15,8 @@ Copyright (c) .NET Foundation. All rights reserved.
$(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets
index 61c5f6a4786c..62e4e8c3bb7f 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommonCrossTargeting.targets
@@ -11,6 +11,7 @@ Copyright (c) .NET Foundation. All rights reserved.
-->
+
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets
index 74e6367225fb..f93b3da32c37 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.Common.targets
@@ -22,16 +22,6 @@ Copyright (c) .NET Foundation. All rights reserved.
$(MicrosoftNETBuildTasksDirectory)Microsoft.NET.Build.Tasks.dll
-
- 1.0.0
-
- $(VersionPrefix)-$(VersionSuffix)
- $(VersionPrefix)
- $(AssemblyName)
- $(Authors)
- $(AssemblyName)
- $(AssemblyName)
-
diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs
index 10ba115d767b..f8eb7e74fe8e 100644
--- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs
+++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToControlGeneratedAssemblyInfo.cs
@@ -9,6 +9,7 @@
using Xunit;
using FluentAssertions;
using static Microsoft.NET.TestFramework.Commands.MSBuildTest;
+using System.Runtime.InteropServices;
namespace Microsoft.NET.Build.Tests
{
@@ -82,5 +83,34 @@ public void It_respects_opt_outs(string attributeToOptOut)
actualInfo.Should().Equal(expectedInfo);
}
+
+ [Theory]
+ [InlineData("netcoreapp1.0")]
+ [InlineData("net45")]
+ public void It_respects_version_prefix(string targetFramework)
+ {
+ if (targetFramework == "net45" && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ return;
+ }
+
+ var testAsset = _testAssetsManager
+ .CopyTestAsset("HelloWorld", identifier: targetFramework)
+ .WithSource()
+ .Restore("", $"/p:OutputType=Library;TargetFramework={targetFramework}");
+
+ var buildCommand = new BuildCommand(Stage0MSBuild, testAsset.TestRoot);
+ buildCommand
+ .Execute($"/p:OutputType=Library;TargetFramework={targetFramework};VersionPrefix=1.2.3")
+ .Should()
+ .Pass();
+
+ var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory(targetFramework).FullName, "HelloWorld.dll");
+ var info = AssemblyInfo.Get(assemblyPath);
+
+ info["AssemblyVersionAttribute"].Should().Be("1.2.3.0");
+ info["AssemblyFileVersionAttribute"].Should().Be("1.2.3.0");
+ info["AssemblyInformationalVersionAttribute"].Should().Be("1.2.3");
+ }
}
}