Skip to content

Commit ca1940c

Browse files
committed
Prefer Content over None for finding JS module files
1 parent d220b88 commit ca1940c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/RazorSdk/Targets/Microsoft.NET.Sdk.Razor.JSModules.targets

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ Copyright (c) .NET Foundation. All rights reserved.
6666

6767
<ItemGroup>
6868
<_JSModuleCandidates Include="@(StaticWebAsset)" Condition="'%(SourceType)' == 'Discovered'" />
69+
70+
<!-- To avoid situations where the content is defined twice, if the user defines the JS module explicitly as
71+
a content item, we'll prefer that over the potential item in the None item group
72+
-->
73+
<_JSFileModuleCandidates Include="@(Content)" />
74+
<_JSFileModuleNoneCandidates Include="@(None)" Exclude="@(Content)" />
75+
<_JSFileModuleCandidates Include="@(_JSFileModuleNoneCandidates)" />
6976
</ItemGroup>
7077

7178
<!-- This runs after we've discovered the original set of files, we already found the assets in the wwwroot, and here we just need
@@ -84,7 +91,7 @@ Copyright (c) .NET Foundation. All rights reserved.
8491

8592
<!-- Find JS module files -->
8693
<!-- **/*.razor.js -->
87-
<DiscoverStaticWebAssets Candidates="@(None);@(Content)"
94+
<DiscoverStaticWebAssets Candidates="@(_JSFileModuleCandidates)"
8895
SourceId="$(PackageId)"
8996
Pattern="**/*.razor.js"
9097
ContentRoot="$(MSBuildProjectDirectory)"
@@ -94,7 +101,7 @@ Copyright (c) .NET Foundation. All rights reserved.
94101
</DiscoverStaticWebAssets>
95102

96103
<!-- **/*.cshtml.js -->
97-
<DiscoverStaticWebAssets Candidates="@(None);@(Content)"
104+
<DiscoverStaticWebAssets Candidates="@(_JSFileModuleCandidates)"
98105
SourceId="$(PackageId)"
99106
Pattern="**/*.cshtml.js"
100107
ContentRoot="$(MSBuildProjectDirectory)"

0 commit comments

Comments
 (0)