Skip to content

Commit

Permalink
Make sure project properties initialize after source control
Browse files Browse the repository at this point in the history
If source control information is supported, make sure we automatically take a dependency on InitializeSourceControlInformation.

We take the chance to also rename the old property `InjectThisAssemblyProjectDependsOn` to `PrepareProjectPropertiesDependsOn` which aligns better with the new target.
  • Loading branch information
kzu committed Nov 21, 2024
1 parent fe8efd0 commit ec77de1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ThisAssembly.Project/ThisAssembly.Project.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
</ItemGroup>

<PropertyGroup>
<InjectThisAssemblyProjectDependsOn Condition="'$(SourceControlInformationFeatureSupported)' == 'true'">
<!-- Backwards compability for original property name -->
<PrepareProjectPropertiesDependsOn>$(InjectThisAssemblyProjectDependsOn)</PrepareProjectPropertiesDependsOn>
<PrepareProjectPropertiesDependsOn Condition="'$(SourceControlInformationFeatureSupported)' == 'true'">
InitializeSourceControlInformation
</InjectThisAssemblyProjectDependsOn>
</PrepareProjectPropertiesDependsOn>
</PropertyGroup>

<Target Name="PrepareProjectProperties" BeforeTargets="PrepareConstants">
<Target Name="PrepareProjectProperties" BeforeTargets="PrepareConstants" DependsOnTargets="$(PrepareProjectPropertiesDependsOn)">
<ItemGroup>
<ProjectPropertyDistinct Include="@(ProjectProperty -> Distinct())" />
</ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions src/ThisAssembly.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public void CanUseProjectFullFileContents()
Assert.False(ThisAssembly.Project.ProjectFile.StartsWith("|"));
}

/// <summary />
[Fact]
public void CanUseProjectRepositoryUrl()
{
Assert.NotEmpty(ThisAssembly.Project.RepositoryUrl);
}

/// <summary />
[Fact]
public void CanUseConstants()
Expand Down

0 comments on commit ec77de1

Please sign in to comment.