Skip to content

Commit

Permalink
Merge pull request #1050 from dotnet/mergev3.6
Browse files Browse the repository at this point in the history
Merge v3.6 to main
  • Loading branch information
AArnott authored May 17, 2024
2 parents 327e400 + 17a14fa commit 82b9858
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
11 changes: 7 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ Param(

$msbuildCommandLine = "dotnet build `"$PSScriptRoot\Nerdbank.GitVersioning.sln`" /m /verbosity:$MsBuildVerbosity /nologo /p:Platform=`"Any CPU`" /t:build,pack"

if (Test-Path "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll") {
$msbuildCommandLine += " /logger:`"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll`""
}

if ($Configuration) {
$msbuildCommandLine += " /p:Configuration=$Configuration"
}
Expand All @@ -34,6 +30,13 @@ try {
}
}

if ($PSCmdlet.ShouldProcess('src/nbgv', 'dotnet publish')) {
dotnet publish src/nbgv -c $Configuration -o src/nerdbank-gitversioning.npm/out/nbgv.cli/tools/net6.0/any
if ($LASTEXITCODE -ne 0) {
throw "dotnet publish failed"
}
}

if ($PSCmdlet.ShouldProcess("$PSScriptRoot\src\nerdbank-gitversioning.npm", "gulp")) {
cd "$PSScriptRoot\src\nerdbank-gitversioning.npm"
yarn install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public class BitbucketCloud : ICloudBuild
public bool IsPullRequest => !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("BITBUCKET_PR_ID"));

/// <inheritdoc />
public string BuildingBranch => Environment.GetEnvironmentVariable("BITBUCKET_BRANCH");
public string BuildingBranch => CloudBuild.ShouldStartWith(Environment.GetEnvironmentVariable("BITBUCKET_BRANCH"), "refs/heads/");

/// <inheritdoc />
public string BuildingTag => Environment.GetEnvironmentVariable("BITBUCKET_TAG");
public string BuildingTag => CloudBuild.ShouldStartWith(Environment.GetEnvironmentVariable("BITBUCKET_TAG"), "refs/tags/");

/// <inheritdoc />
public string GitCommitId => Environment.GetEnvironmentVariable("BITBUCKET_COMMIT");
Expand Down
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning/VersionOracle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public IDictionary<string, string> CloudBuildVersionVars
/// <summary>
/// Gets the version to use for NPM packages.
/// </summary>
public string NpmPackageVersion => $"{this.Version.ToStringSafe(3)}{this.PrereleaseVersion}";
public string NpmPackageVersion => this.SemVer2;

/// <summary>
/// Gets a SemVer 1.0 compliant string that represents this version, including the -COMMITID suffix
Expand Down
12 changes: 11 additions & 1 deletion src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ private void GenerateAssemblyAttributes()
this.generator.DeclareAttribute(typeof(AssemblyCopyrightAttribute), this.AssemblyCopyright);
}
}

this.generator.EndAssemblyAttributes();
}

private List<KeyValuePair<string, (object Value, bool EmitIfEmpty /* Only applies to string values */)>> GetFieldsForThisAssembly()
Expand Down Expand Up @@ -658,6 +660,10 @@ internal virtual void StartAssemblyAttributes()
{
}

internal virtual void EndAssemblyAttributes()
{
}

internal abstract void DeclareAttribute(Type type, string arg);

internal abstract void StartThisAssemblyClass();
Expand Down Expand Up @@ -726,6 +732,11 @@ internal override void StartAssemblyAttributes()
this.CodeBuilder.AppendLine($"namespace {this.Namespace}");
}

internal override void EndAssemblyAttributes()
{
this.CodeBuilder.AppendLine("do()");
}

internal override void DeclareAttribute(Type type, string arg)
{
this.CodeBuilder.AppendLine($"[<assembly: global.{type.FullName}(\"{arg}\")>]");
Expand All @@ -738,7 +749,6 @@ internal override void EndThisAssemblyClass()

internal override void StartThisAssemblyClass()
{
this.CodeBuilder.AppendLine("do()");
this.CodeBuilder.AppendLine($"#if {CompilerDefinesAroundGeneratedCodeAttribute}");
this.CodeBuilder.AppendLine($"[<global.System.CodeDom.Compiler.GeneratedCode(\"{GeneratorName}\",\"{GeneratorVersion}\")>]");
this.CodeBuilder.AppendLine("#endif");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
<PropertyGroup>
<VersionSourceFile>$([MSBuild]::NormalizePath('$(IntermediateOutputPath)', '$(AssemblyName).Version$(DefaultLanguageSourceExtension)'))</VersionSourceFile>
<NewVersionSourceFile>$(VersionSourceFile).new</NewVersionSourceFile>
<!-- Workaround WPF inner build RootNamespace changing: https://github.com/dotnet/Nerdbank.GitVersioning/issues/175 -->
<NBGV_RootNamespace>$(RootNamespace)</NBGV_RootNamespace>
<NBGV_RootNamespace Condition="$(RootNamespace.EndsWith('_wpftmp')) and '$(_TargetAssemblyProjectName)'!=''">$(_TargetAssemblyProjectName)</NBGV_RootNamespace>
</PropertyGroup>
<ItemGroup>
<AdditionalThisAssemblyFields Include="NuGetPackageVersion" String="$(NuGetPackageVersion)" Condition="'$(NBGV_ThisAssemblyIncludesPackageVersion)' == 'true'" />
Expand All @@ -154,7 +157,7 @@
AssemblyFileVersion="$(AssemblyFileVersion)"
AssemblyInformationalVersion="$(AssemblyInformationalVersion)"
AssemblyName="$(AssemblyName)"
RootNamespace="$(RootNamespace)"
RootNamespace="$(NBGV_RootNamespace)"
ThisAssemblyNamespace="$(NBGV_ThisAssemblyNamespace)"
AssemblyOriginatorKeyFile="$(AssemblyOriginatorKeyFile)"
AssemblyTitle="$(AssemblyTitle)"
Expand Down
4 changes: 2 additions & 2 deletions test/Nerdbank.GitVersioning.Tests/AssemblyInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ namespace AssemblyInfo
[<assembly: global.System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: global.System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: global.System.Reflection.AssemblyInformationalVersionAttribute("""")>]
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
do()
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<global.System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>]
#endif
#if NET40_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
Expand Down

0 comments on commit 82b9858

Please sign in to comment.