Fix intermediate path for service worker assets (#21128)
This commit is contained in:
parent
147f5758c6
commit
2a97de0344
|
|
@ -5,7 +5,7 @@
|
|||
BeforeTargets="_ResolveBlazorOutputs;_ResolveBlazorFilesToCompress">
|
||||
|
||||
<PropertyGroup>
|
||||
<_ServiceWorkerAssetsManifestIntermediateOutputPath>$(_BlazorIntermediateOutputPath)$(ServiceWorkerAssetsManifest)</_ServiceWorkerAssetsManifestIntermediateOutputPath>
|
||||
<_ServiceWorkerAssetsManifestIntermediateOutputPath>$([MSBuild]::MakeRelative($(MSBuildProjectDirectory), $(_BlazorIntermediateOutputPath)))$(ServiceWorkerAssetsManifest)</_ServiceWorkerAssetsManifestIntermediateOutputPath>
|
||||
<_ServiceWorkerAssetsManifestFullPath>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(_ServiceWorkerAssetsManifestIntermediateOutputPath)'))</_ServiceWorkerAssetsManifestFullPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
<SourceId>$(PackageId)</SourceId>
|
||||
<ContentRoot>$([MSBuild]::NormalizeDirectory('$(TargetDir)wwwroot\'))</ContentRoot>
|
||||
<BasePath>$(StaticWebAssetBasePath)</BasePath>
|
||||
<RelativePath>$([MSBuild]::MakeRelative($([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(_BlazorIntermediateOutputPath)')), $(_ServiceWorkerAssetsManifestFullPath)))</RelativePath>
|
||||
<RelativePath>$(ServiceWorkerAssetsManifest)</RelativePath>
|
||||
</_ManifestStaticWebAsset>
|
||||
|
||||
<StaticWebAsset Include="@(_ManifestStaticWebAsset)" />
|
||||
|
|
|
|||
|
|
@ -325,6 +325,30 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
|
|||
Assert.FileDoesNotExist(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.West.dll");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Build_WithCustomOutputPath_Works()
|
||||
{
|
||||
// Arrange
|
||||
using var project = ProjectDirectory.Create("standalone", additionalProjects: new[] { "razorclasslibrary" });
|
||||
|
||||
project.AddDirectoryBuildContent(
|
||||
@"<PropertyGroup>
|
||||
<BaseOutputPath>$(MSBuildThisFileDirectory)build\bin\</BaseOutputPath>
|
||||
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)build\obj\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>");
|
||||
|
||||
var result = await MSBuildProcessManager.DotnetMSBuild(project, args: "/restore");
|
||||
Assert.BuildPassed(result);
|
||||
|
||||
var compressedFilesPath = Path.Combine(
|
||||
project.DirectoryPath,
|
||||
"build",
|
||||
project.IntermediateOutputDirectory,
|
||||
"compressed");
|
||||
|
||||
Assert.True(Directory.Exists(compressedFilesPath));
|
||||
}
|
||||
|
||||
private static GenerateBlazorBootJson.BootJsonData ReadBootJsonData(MSBuildResult result, string path)
|
||||
{
|
||||
return JsonSerializer.Deserialize<GenerateBlazorBootJson.BootJsonData>(
|
||||
|
|
|
|||
|
|
@ -172,6 +172,20 @@ $@"<Project>
|
|||
File.WriteAllText(ProjectFilePath, updated);
|
||||
}
|
||||
|
||||
internal void AddDirectoryBuildContent(string content)
|
||||
{
|
||||
if (content == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(content));
|
||||
}
|
||||
|
||||
var filepath = Path.Combine(DirectoryPath, "Directory.Build.props");
|
||||
|
||||
var existing = File.ReadAllText(filepath);
|
||||
var updated = existing.Replace("<!-- Test Placeholder -->", content);
|
||||
File.WriteAllText(filepath, updated);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (PreserveWorkingDirectory)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<Project>
|
||||
<Import Project="Before.Directory.Build.props" Condition="Exists('Before.Directory.Build.props')" />
|
||||
|
||||
<!-- Test Placeholder -->
|
||||
|
||||
<PropertyGroup>
|
||||
<RepoRoot Condition="'$(RepoRoot)' ==''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), global.json))\</RepoRoot>
|
||||
<ComponentsRoot>$(RepoRoot)src\Components\</ComponentsRoot>
|
||||
|
|
|
|||
Loading…
Reference in New Issue