[Static web assets][Fixes #AspNetCore/17079] PublishSingleFile results in 404 errors for Nuget components
\n\nCommit migrated from 53dd89a41d
This commit is contained in:
parent
9328e4723e
commit
0c907a8225
|
|
@ -506,14 +506,15 @@ Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
<RelativePath>$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\%(BasePath)\%(RelativePath)'))'))</RelativePath>
|
<RelativePath>$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\%(BasePath)\%(RelativePath)'))'))</RelativePath>
|
||||||
|
|
||||||
</_ExternalPublishStaticWebAsset>
|
</_ExternalPublishStaticWebAsset>
|
||||||
|
|
||||||
<!-- Remove any existing external static web asset that might have been added as part of the
|
<!-- Remove any existing external static web asset that might have been added as part of the
|
||||||
regular publish pipeline. -->
|
regular publish pipeline. -->
|
||||||
<ResolvedFileToPublish Remove="@(_ExternalPublishStaticWebAsset)" />
|
<ResolvedFileToPublish Remove="@(_ExternalPublishStaticWebAsset)" />
|
||||||
|
|
||||||
<ResolvedFileToPublish Include="@(_ExternalPublishStaticWebAsset)" />
|
<ResolvedFileToPublish Include="@(_ExternalPublishStaticWebAsset)">
|
||||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||||
|
</ResolvedFileToPublish>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
|
|
||||||
protected string PublishOutputPath => Path.Combine(OutputPath, "publish");
|
protected string PublishOutputPath => Path.Combine(OutputPath, "publish");
|
||||||
|
|
||||||
|
protected string GetRidSpecificPublishOutputPath(string rid) => Path.Combine(OutputPath, rid, "publish");
|
||||||
|
|
||||||
// Used by the test framework to set the project that we're working with
|
// Used by the test framework to set the project that we're working with
|
||||||
internal static ProjectDirectory Project
|
internal static ProjectDirectory Project
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,31 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
||||||
Assert.FileDoesNotExist(result, PublishOutputPath, "AppWithPackageAndP2PReference.StaticWebAssets.xml");
|
Assert.FileDoesNotExist(result, PublishOutputPath, "AppWithPackageAndP2PReference.StaticWebAssets.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[InitializeTestProject("AppWithPackageAndP2PReference", additionalProjects: new[] { "ClassLibrary", "ClassLibrary2" })]
|
||||||
|
public async Task Publish_CopiesStaticWebAssetsToDestinationFolder_PublishSingleFile()
|
||||||
|
{
|
||||||
|
var runtimeIdentifier = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "win-x64" : (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "osx-x64" : "linux-x64");
|
||||||
|
var result = await DotnetMSBuild("Publish", $"/restore /p:PublishSingleFile=true /p:RuntimeIdentifier={runtimeIdentifier}");
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
var publishOutputPath = GetRidSpecificPublishOutputPath(runtimeIdentifier);
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary", "js", "project-transitive-dep.js"));
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary", "js", "project-transitive-dep.v4.js"));
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary2", "css", "site.css"));
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary2", "js", "project-direct-dep.js"));
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryDirectDependency", "css", "site.css"));
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryDirectDependency", "js", "pkg-direct-dep.js"));
|
||||||
|
Assert.FileExists(result, publishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryTransitiveDependency", "js", "pkg-transitive-dep.js"));
|
||||||
|
|
||||||
|
// Validate that static web assets don't get published as content too on their regular path
|
||||||
|
Assert.FileDoesNotExist(result, publishOutputPath, Path.Combine("wwwroot", "js", "project-transitive-dep.js"));
|
||||||
|
Assert.FileDoesNotExist(result, publishOutputPath, Path.Combine("wwwroot", "js", "project-transitive-dep.v4.js"));
|
||||||
|
|
||||||
|
// Validate that the manifest never gets copied
|
||||||
|
Assert.FileDoesNotExist(result, publishOutputPath, "AppWithPackageAndP2PReference.StaticWebAssets.xml");
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[InitializeTestProject("AppWithPackageAndP2PReference", additionalProjects: new[] { "ClassLibrary", "ClassLibrary2" })]
|
[InitializeTestProject("AppWithPackageAndP2PReference", additionalProjects: new[] { "ClassLibrary", "ClassLibrary2" })]
|
||||||
public async Task Publish_WithBuildReferencesDisabled_CopiesStaticWebAssetsToDestinationFolder()
|
public async Task Publish_WithBuildReferencesDisabled_CopiesStaticWebAssetsToDestinationFolder()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue