Skip to content

Commit

Permalink
Merge pull request #11559 from sfoslund/RepoUrlAttribute
Browse files Browse the repository at this point in the history
Adding RepositoryUrl to generated AssemblyInfo
  • Loading branch information
sfoslund authored May 5, 2020
2 parents 1554522 + 0d5d60c commit 16b4b92
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ Copyright (c) .NET Foundation. All rights reserved.
<AssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute" Condition="'$(AssemblyVersion)' != '' and '$(GenerateAssemblyVersionAttribute)' == 'true'">
<_Parameter1>$(AssemblyVersion)</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(RepositoryUrl)' != '' or '$(PublishRepositoryUrl)' == 'true'" >
<_Parameter1>RepositoryUrl</_Parameter1>
<_Parameter2 Condition="'$(RepositoryUrl)' != ''">$(RepositoryUrl)</_Parameter2>
<_Parameter2 Condition="'$(RepositoryUrl)' == ''">$(PrivateRepositoryUrl)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute" Condition="'$(NeutralLanguage)' != '' and '$(GenerateNeutralResourcesLanguageAttribute)' == 'true'">
<_Parameter1>$(NeutralLanguage)</_Parameter1>
</AssemblyAttribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,5 +595,38 @@ public void GenerateUserSecretsForTestProject()

AssemblyInfo.Get(assemblyPath)["UserSecretsIdAttribute"].Should().Be("SecretsIdValue");
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void It_includes_repository_url(bool privateRepo)
{
var fakeUrl = "fakeUrl";
var testProject = new TestProject()
{
Name = "RepoUrlProject",
IsSdkProject = true,
TargetFrameworks = "netcoreapp3.1"
};

if (privateRepo)
{
testProject.AdditionalProperties["PublishRepositoryUrl"] = "true";
testProject.AdditionalProperties["PrivateRepositoryUrl"] = fakeUrl;
}
else
{
testProject.AdditionalProperties["RepositoryUrl"] = fakeUrl;
}

var testAsset = _testAssetsManager.CreateTestProject(testProject);

var buildCommand = new BuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
buildCommand.Execute().Should().Pass();

var assemblyPath = Path.Combine(buildCommand.GetOutputDirectory("netcoreapp3.1").FullName, testProject.Name + ".dll");

AssemblyInfo.Get(assemblyPath)["AssemblyMetadataAttribute"].Should().Be("RepositoryUrl:" + fakeUrl);
}
}
}

0 comments on commit 16b4b92

Please sign in to comment.