Skip to content

Commit

Permalink
Remove Razor tool assembly dependency in SWA
Browse files Browse the repository at this point in the history
  • Loading branch information
MackinnonBuck committed Apr 26, 2023
1 parent d1883b0 commit a3790af
Show file tree
Hide file tree
Showing 10 changed files with 904 additions and 942 deletions.
43 changes: 27 additions & 16 deletions src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ Copyright (c) .NET Foundation. All rights reserved.
ResolveRazorEmbeddedResources;
</ResolveRazorCompileInputsDependsOn>

<ResolveScopedCssOutputsDependsOn>
$(ResolveScopedCssOutputsDependsOn);
ResolveCssScopes;
</ResolveScopedCssOutputsDependsOn>

<DebugSymbolsProjectOutputGroupDependsOn>
$(DebugSymbolsProjectOutputGroupDependsOn);
_RazorAddDebugSymbolsProjectOutputGroupOutput
Expand All @@ -198,16 +203,6 @@ Copyright (c) .NET Foundation. All rights reserved.
ResolveRazorComponentInputs;
AssignRazorComponentTargetPaths
</_RazorGenerateComponentDesignTimeDependsOn>

<AssignRazorComponentTargetPathsDependsOn Condition="'$(ScopedCssEnabled)' == 'true'">
$(AssignRazorComponentTargetPathsDependsOn);
ResolveCssScopes;
</AssignRazorComponentTargetPathsDependsOn>

<AssignRazorGenerateTargetPathsDependsOn Condition="'$(ScopedCssEnabled)' == 'true'">
$(AssignRazorGenerateTargetPathsDependsOn);
ResolveCssScopes;
</AssignRazorGenerateTargetPathsDependsOn>
</PropertyGroup>

<!--
Expand Down Expand Up @@ -554,6 +549,26 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
</Target>

<!-- This target validates that there is at most one scoped css file per component, that there are no scoped css files without a
matching component, and then adds the associated scope to the razor components that have a matching scoped css file.
-->
<Target
Name="ResolveCssScopes"
Condition="'$(ScopedCssEnabled)' == 'true'"
BeforeTargets="AssignRazorComponentTargetPaths;AssignRazorGenerateTargetPaths"
DependsOnTargets="ComputeCssScope;ResolveRazorComponentInputs;ResolveRazorGenerateInputs">
<ApplyCssScopes RazorComponents="@(RazorComponent)" RazorGenerate="@(RazorGenerate)" ScopedCss="@(_ScopedCss)">
<Output TaskParameter="RazorComponentsWithScopes" ItemName="_RazorComponentsWithScopes" />
<Output TaskParameter="RazorGenerateWithScopes" ItemName="_RazorGenerateWithScopes" />
</ApplyCssScopes>
<ItemGroup>
<RazorComponent Remove="@(_RazorComponentsWithScopes)" />
<RazorComponent Include="@(_RazorComponentsWithScopes)" />
<RazorGenerate Remove="@(_RazorGenerateWithScopes)" />
<RazorGenerate Include="@(_RazorGenerateWithScopes)" />
</ItemGroup>
</Target>

<!--
Temporarary workaround for https://github.com/dotnet/aspnetcore/issues/6859. This can be removed after a VS insertion with a newer copy of the DesignTime targets.
-->
Expand All @@ -564,9 +579,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</Content>
</ItemGroup>

<Target Name="AssignRazorComponentTargetPaths"
Condition="'@(RazorComponent)' != ''"
DependsOnTargets="$(AssignRazorComponentTargetPathsDependsOn)">
<Target Name="AssignRazorComponentTargetPaths" Condition="'@(RazorComponent)' != ''">
<AssignTargetPath Files="@(RazorComponent)" RootFolder="$(MSBuildProjectDirectory)">
<Output TaskParameter="AssignedFiles" ItemName="RazorComponentWithTargetPath" />
</AssignTargetPath>
Expand All @@ -586,9 +599,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
</Target>

<Target Name="AssignRazorGenerateTargetPaths"
Condition="'@(RazorGenerate)' != ''"
DependsOnTargets="$(AssignRazorGenerateTargetPathsDependsOn)">
<Target Name="AssignRazorGenerateTargetPaths" Condition="'@(RazorGenerate)' != ''">
<AssignTargetPath Files="@(RazorGenerate)" RootFolder="$(MSBuildProjectDirectory)">
<Output TaskParameter="AssignedFiles" ItemName="RazorGenerateWithTargetPath" />
</AssignTargetPath>
Expand Down
1 change: 0 additions & 1 deletion src/RazorSdk/Tool/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public Application(
Commands.Add(new ShutdownCommand(this));
Commands.Add(new DiscoverCommand(this));
Commands.Add(new GenerateCommand(this));
Commands.Add(new RewriteCssCommand(this));
}

public CancellationToken CancellationToken { get; }
Expand Down
Loading

0 comments on commit a3790af

Please sign in to comment.