Skip to content

Commit 1053060

Browse files
committed
Add link tests
1 parent df26349 commit 1053060

File tree

7 files changed

+29
-2
lines changed

7 files changed

+29
-2
lines changed

src/Components/Blazor/Build/src/targets/StaticWebAssets.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<_ContentLinkedIntoWwwroot
4040
Include="@(_ContentWithWwrootLinkAttribute)"
41-
Condition="@(_ContentWithWwrootLinkAttribute) != '' and '%(CopyToPublishDirectory)' != 'false'">
41+
Condition="@(_ContentWithWwrootLinkAttribute) != '' and '%(_ContentWithWwrootLinkAttribute.CopyToPublishDirectory)' != 'false'">
4242
<!-- This gets rid of wwwroot\ -->
4343
<RelativePath>$([System.String]::Copy('%(Link)').Substring(8))</RelativePath>
4444
</_ContentLinkedIntoWwwroot>

src/Components/Blazor/Build/test/BuildIntegrationTests/PublishIntegrationTest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PublishIntegrationTest
1313
public async Task Publish_WithDefaultSettings_Works()
1414
{
1515
// Arrange
16-
using var project = ProjectDirectory.Create("standalone", additionalProjects: new [] { "razorclasslibrary" });
16+
using var project = ProjectDirectory.Create("standalone", additionalProjects: new [] { "razorclasslibrary", "LinkBaseToWebRoot" });
1717
var result = await MSBuildProcessManager.DotnetMSBuild(project, "Publish");
1818

1919
Assert.BuildPassed(result);
@@ -35,6 +35,12 @@ public async Task Publish_WithDefaultSettings_Works()
3535
// Verify static assets are in the publish directory
3636
Assert.FileExists(result, blazorPublishDirectory, "dist", "index.html");
3737

38+
// Verify link item assets are in the publish directory
39+
Assert.FileExists(result, blazorPublishDirectory, "dist", "js", "LinkedScript.js");
40+
var cssFile = Assert.FileExists(result, blazorPublishDirectory, "dist", "css", "site.css");
41+
Assert.FileContains(result, cssFile, ".publish");
42+
Assert.FileDoesNotExist(result, "dist", "Fake-License.txt");
43+
3844
// Verify web.config
3945
Assert.FileExists(result, publishDirectory, "web.config");
4046
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.publish { }

src/Components/Blazor/Build/testassets/standalone/standalone.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,21 @@
1717
<ProjectReference Include="..\razorclasslibrary\RazorClassLibrary.csproj" />
1818
</ItemGroup>
1919

20+
<ItemGroup>
21+
<!-- These assets should be treated as static web assets for publish purposes -->
22+
<Content Include="..\LinkBaseToWebRoot\**\*.js">
23+
<LinkBase>wwwroot\</LinkBase>
24+
</Content>
25+
26+
<!-- This asset should be ignored as a static web assets as it defines CopyToPublishDirectory="false" -->
27+
<Content Update="wwwroot\css\site.css" CopyToPublishDirectory="false" />
28+
29+
<!-- This asset should be treated as a static web asset and copied into the right location defined by its link attribute. -->
30+
<Content Include="LinkToWebRoot\css\site.css" Link="wwwroot\css\site.css" />
31+
32+
<!-- This asset should not be treated as a static web asset as it is being linked out of the wwwroot folder. -->
33+
<Content Update="wwwroot\Fake-License.txt" Link="Excluded-Static-Web-Assets\Fake-License.txt" />
34+
35+
</ItemGroup>
36+
2037
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.build { }

0 commit comments

Comments
 (0)