-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Refactor MSBuild project files by adding the common property file #4106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
eee06ac
to
f178d17
Compare
👍 for following DRY principle. |
@daxian-dbw Commit to get PS version from Git is ready. If you want I can add it to the PR. It is only add one new Target. |
@iSazonov If the new Target is not huge then add it in and let's review it together. |
The new target is very simple. Also I tried to build a package by Start-PSBuild -Clean -CrossGen -Runtime win10-x64 -Configuration Release
Start-PSPackage -Type msi and got |
2ab1735
to
7d2b520
Compare
It's good that you verified the package generation. But it's the NuGet package that I'm worried. Without |
How can I build the NuGet package? |
PowerShell.Common.props
Outdated
<PS6AdditionalCommits>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[2].Value)</PS6AdditionalCommits> | ||
<PS6CommitSHA>$([System.Text.RegularExpressions.Regex]::Match($(PowerShellVersion), $(RegexGitVersion)).Groups[3].Value)</PS6CommitSHA> | ||
|
||
<RegexSymVer>^(\d+).(\d+).(\d+)-(.+)</RegexSymVer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regular expression will fail when we finally reach the official v6.0.0
(no -beta.N
part anymore).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No plans -rtm
?
In any case I can make the part as optional.
PowerShell.Common.props
Outdated
<Output TaskParameter="ConsoleOutput" PropertyName="PowerShellVersion" /> | ||
</Exec> | ||
|
||
<PropertyGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole <PropertyGroup>
block should be indented since it's part of the <Target>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reverted the commit.
PowerShell.Common.props
Outdated
<PS6PatchVersion>$([System.Text.RegularExpressions.Regex]::Match($(PS6BuildVersion), $(RegexSymVer)).Groups[3].Value)</PS6PatchVersion> | ||
<PS6LabelVersion>$([System.Text.RegularExpressions.Regex]::Match($(PS6BuildVersion), $(RegexSymVer)).Groups[4].Value)</PS6LabelVersion> | ||
|
||
<PS6FormattedVersion Condition="'$(PS6AdditionalCommits)' == ''">$(PS6BuildVersion) SHA: $(PS6CommitSHA)</PS6FormattedVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $(PS6AdditionalCommits)
will never be an empty string, because when there is no additional commit, it should be 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Will fix in next PR.
PowerShell.Common.props
Outdated
<AssemblyVersion>6.0.0.0</AssemblyVersion> | ||
|
||
<ProductVersion>6.0.0-beta.3</ProductVersion> | ||
<InformationalVersion>6.0.0-beta.3</InformationalVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you don't need to hard code them now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit was reverted.
PowerShell.Common.props
Outdated
<GitInfoBaseDir Condition="'$(GitInfoBaseDir)' == ''">$(MSBuildProjectDirectory)/$(GitCDUP)/.git</GitInfoBaseDir> | ||
</PropertyGroup> | ||
|
||
<Exec Command='$(GitExe) --git-dir="$(GitInfoBaseDir)" describe --abbrev=60 --long' ConsoleToMSBuild="true"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with --long
, even if it's right on a tag, you still will get the long version like v6.0.0-beta.3-0-gxxxxxxxxx
. However, when we are right on a tag, we are expecting the GitCommitId to be v6.0.0-beta.3
.
PowerShell.Common.props
Outdated
|
||
<ProductVersion>$(PS6BuildVersion)</ProductVersion> | ||
<!-- PackageVersion>$(PS6BuildVersion)</PackageVersion --> | ||
<InformationalVersion>$(PS6FormattedVersion)</InformationalVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I get from Microsoft.Win32.Registry.AccessControl.dll
:
PS:156> $o | fl ProductVersion, FileVersion, FileName, ProductName
ProductVersion : 4.6.25428.01 built by: dlab-DDVSOWINAGE031. Commit Hash: 644b3ba1fec90828fc31353461b7d1a4aac7ea7f
FileVersion : 4.6.25428.01
FileName : C:\Users\dongbow\Downloads\Microsoft.Win32.Registry.AccessControl.dll
ProductName : Microsoft® .NET Framework
AssemblyInformationalVersion
maps to ProductVersion
, while AssemblyFileVersion
maps to FileVersion
, maybe we should do similar thing in powershell assemblies.
@@ -1,9 +1,6 @@ | |||
using System.Reflection; | |||
using System.Resources; | |||
|
|||
[assembly: AssemblyFileVersionAttribute("3.0.0.0")] | |||
[assembly: AssemblyVersion("3.0.0.0")] | |||
|
|||
[assembly: AssemblyCulture("")] | |||
[assembly: NeutralResourcesLanguage("en-US")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think [assembly: AssemblyCulture("")]
is necessary. We can remove it.
As for [assembly: NeutralResourcesLanguage("en-US")]
it can be replaced by <NeutralLanguage>en-US</NeutralLanguage>
in csproj, and I think this tag can go in PowerShell.Common.props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -1,8 +1,5 @@ | |||
using System.Reflection; | |||
using System.Resources; | |||
|
|||
[assembly: AssemblyFileVersionAttribute("3.0.0.0")] | |||
[assembly: AssemblyVersion("3.0.0.0")] | |||
|
|||
[assembly: AssemblyCulture("")] | |||
[assembly: NeutralResourcesLanguage("en-US")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here and in other files. So for this one, the AssemlbyInfo.cs file can be deleted probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The some AssemlbyInfo.cs files is empty now.
What is the probability that we will not add personal attributes?
Get the tag commit meta info from the target is good, but it raises a problem -- in our release process, we need to be able to build and package powershell core targeting a tag label, say However, with this The reason to create the tag until finishing preparing the release is that issues may come up when or after build/package, and in that case we need check in fixes. If tag is already pushed, then it's super hard to do the fix. Given this, I suggest to separate the |
@PowerShell/powershell-committee reviewed this and is fine with taking the assembly version to 6.0.0 and taking it now to discover customer impact |
@SteveL-MSFT Could we add @PowerShell/powershell-committee argumentations to the PR description if in future customers catch any problems with the change? Also my question is - what is a best practice to ensure assembly backward compatibility? If we follow the best practice, we can recommend the same users to avoid the problem. @daxian-dbw Well, I revert last commit. We can easy pass a ReleaseTag value by ```dotnet build ... /p:"PS6BuildVersion=$ReleaseTag" in Build.psm1. I'll add this in next PR. |
Thanks @iSazonov! Appreciate your quick action. |
PowerShell.Common.props
Outdated
<NeutralLanguage>en-US</NeutralLanguage> | ||
|
||
<ProductVersion>6.0.0-beta.3</ProductVersion> | ||
<InformationalVersion>6.0.0-beta.3</InformationalVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think <ProductVersion>
and InformationalVersion
are probably not needed in this PR. The target
change can bring them back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
PowerShell.Common.props
Outdated
|
||
<FileVersion>6.0.0.0</FileVersion> | ||
<AssemblyVersion>6.0.0.0</AssemblyVersion> | ||
<NeutralLanguage>en-US</NeutralLanguage> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need the <VersionPrefix>6.0.0</VersionPrefix>
to represent the project version, so that the NuGet package versions are correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
Done.
For clarify. I only found the VersionPrefix in Microsoft.NET.DefaultAssemblyInfo.targets where it define Version
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, Version composition works as this: If Version is unset, use VersionPrefix (defaults to 1.0.0 if unset) and - if present - append VersionSuffix.
All other version are then defaulted to whatever Version is.
Quoted from StackOverflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AssemblyVersion
and FileVesion
are inferred by Version
by default. But if they are set, it is considered an override of the default inference.
Not only these 2 versions, ProductVersion
and InformationalVersion
are also inferred from Version
if they are not set. (and ProductVersion
is by default the same as InformationVersion
)
@@ -1,9 +1,2 @@ | |||
using System.Reflection; | |||
using System.Resources; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably can remove this file now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
<AssemblyOriginatorKeyFile>../signing/visualstudiopublic.snk</AssemblyOriginatorKeyFile> | ||
55F <SignAssembly>true</SignAssembly> | ||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> | ||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> | ||
<GenerateNeutralResourcesLanguageAttribute>false< 10669 /GenerateNeutralResourcesLanguageAttribute> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<GenerateNeutralResourcesLanguageAttribute>
should be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -1,8 +1,2 @@ | |||
using System.Reflection; | |||
using System.Resources; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
<NoWarn>$(NoWarn);CS1570</NoWarn> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<DelaySign>true</DelaySign> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tag is now needed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed now 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
<AssemblyOriginatorKeyFile>../signing/visualstudiopublic.snk</AssemblyOriginatorKeyFile> | ||
<SignAssembly>true</SignAssembly> | ||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> | ||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> | ||
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tag can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -1,4 +1 @@ | |||
using System.Reflection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -1,4 +1 @@ | |||
using System.Reflection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
<AssemblyOriginatorKeyFile>../signing/visualstudiopublic.snk</AssemblyOriginatorKeyFile> | ||
<SignAssembly>true</SignAssembly> | ||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute> | ||
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute> | ||
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tag can be removed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @iSazonov Thanks for your hard work on this and your patience as well.
@daxian-dbw Thanks for review! I am ready to continue the work in new PR. |
Reopen #3917
Related #3400
Motivation
We inherited old assembly file versions from Windows PowerShell.
Currently we shouldn't set versions of assemblies statically in
AssemblyInfo.cs
files, we should set versions of assemblies dynamically by MSBuild as discussed in #3690.Fix
AssemblyVersion
andAssemblyFileVersionAttribute
attributes fromAssemblyInfo.cs
files.PowerShell.Common.props
in all csproj files.Follow-Up Work
In the PR we temporarily hard code assembly versions as "6.0.0-beta.3".
Later we should set a dll version based on GitCommitId.
Additional considerations
In previous PR #3917 we caught some problems and we should fix it here:
AssemblyVersion
3.0.00 (AssemblyFileVersionAttribute
?)AssemblyVersion
by MSBuildNote
Quoted from @SteveL-MSFT: