Skip to content

Commit

Permalink
Only run targets when necessary and no earlier
Browse files Browse the repository at this point in the history
When we add items/propeties that need to be visible to the generators, we only really need to run before the editorconfig is emitted, and no earlier. This happens right before compilation, so it's a safe late-stage target to depend on.

We cannot run later since that would mean outdated info to the generator, but this should avoid early-run issues such as devlooped/GitInfo#260.
  • Loading branch information
kzu committed Mar 22, 2023
1 parent ff4e3f1 commit 64ad452
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ThisAssembly.Constants/ThisAssembly.Constants.targets
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</Target>

<Target Name="_InjectConstantAdditionalFiles"
BeforeTargets="PrepareForBuild;CompileDesignTime;GenerateMSBuildEditorConfigFileShouldRun"
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun"
DependsOnTargets="PrepareResourceNames;PrepareConstants">
<ItemGroup>
<AdditionalFiles Include="@(Constant)" SourceItemType="Constant" />
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Project/ThisAssembly.Project.targets
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<Target Name="InjectThisAssemblyProject" DependsOnTargets="$(InjectThisAssemblyProjectDependsOn)"
BeforeTargets="PrepareForBuild;CompileDesignTime;GenerateMSBuildEditorConfigFileShouldRun">
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun">
<ItemGroup>
<ProjectPropertyDistinct Include="@(ProjectProperty -> Distinct())" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Resources/ThisAssembly.Resources.targets
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemDefinitionGroup>

<Target Name="_InjectResourcesAdditionalFiles"
BeforeTargets="PrepareForBuild;CompileDesignTime;GenerateMSBuildEditorConfigFileShouldRun"
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun"
DependsOnTargets="PrepareResourceNames">
<ItemGroup>
<EmbeddedResource Condition="!$([System.IO.Path]::IsPathRooted('%(RelativeDir)')) OR '%(Link)' != ''">
Expand Down
2 changes: 1 addition & 1 deletion src/ThisAssembly.Strings/ThisAssembly.Strings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</ItemGroup>

<Target Name="_InjectResxAdditionalFiles"
BeforeTargets="PrepareForBuild;CompileDesignTime;GenerateMSBuildEditorConfigFileShouldRun"
BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun"
DependsOnTargets="PrepareResourceNames">
<ItemGroup>
<ResxCode Include="@(EmbeddedResource)"
Expand Down

0 comments on commit 64ad452

Please sign in to comment.