Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Static web assets] Account for HintPath when we compute the build assets #19873

Merged
merged 8 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ Copyright (c) .NET Foundation. All rights reserved.

<Target Name="ResolveStaticWebAssetsConfiguration">
<PropertyGroup>
<_StaticWebAssetsManifestBase>$(BaseIntermediateOutputPath)$(Configuration)\$(TargetFramework.ToLowerInvariant())\</_StaticWebAssetsManifestBase>
<_StaticWebAssetsManifestBase>$(BaseIntermediateOutputPath)$(Configuration)\</_StaticWebAssetsManifestBase>
<_StaticWebAssetsManifestBase Condition="'$(AppendTargetFrameworkToOutputPath)' != 'false'">$(_StaticWebAssetsManifestBase)\$(TargetFramework.ToLowerInvariant())\</_StaticWebAssetsManifestBase>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javiercn marked this conversation as resolved.
Show resolved Hide resolved
<StaticWebAssetBasePath Condition="'$(StaticWebAssetBasePath)' == ''">_content/$(PackageId)</StaticWebAssetBasePath>
<StaticWebAssetProjectMode Condition="'$(StaticWebAssetProjectMode)' == ''">Default</StaticWebAssetProjectMode>
<StaticWebAssetBuildManifestPath>$(_StaticWebAssetsManifestBase)staticwebassets.build.json</StaticWebAssetBuildManifestPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,46 @@ public void PublishProjectWithReferences_NoBuild_GeneratesPublishJsonManifestAnd
intermediateOutputPath);
}

[Fact]
public void PublishProjectWithReferences_AppendTargetFrameworkToOutputPathFalse_GeneratesPublishJsonManifestAndCopiesPublishAssets()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
var testAsset = "RazorAppWithPackageAndP2PReference";
ProjectDirectory = CreateAspNetSdkTestAsset(testAsset);

var restore = new RestoreCommand(Log, Path.Combine(ProjectDirectory.TestRoot, "AppWithPackageAndP2PReference"));
restore.Execute().Should().Pass();

var publish = new PublishCommand(Log, Path.Combine(ProjectDirectory.TestRoot, "AppWithPackageAndP2PReference"));
publish.WithWorkingDirectory(ProjectDirectory.Path);
publish.Execute("/p:AppendTargetFrameworkToOutputPath=false", "/bl").Should().Pass();

var intermediateOutputPath = publish.GetIntermediateDirectory("", "Debug").ToString();
var publishPath = publish.GetOutputDirectory("", "Debug").ToString();

// GenerateStaticWebAssetsManifest should generate the manifest file.
var path = Path.Combine(intermediateOutputPath, "staticwebassets.build.json");
new FileInfo(path).Should().Exist();
AssertManifest(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(path)),
LoadBuildManifest());

// GenerateStaticWebAssetsManifest should copy the file to the output folder.
var finalPath = Path.Combine(publishPath, "AppWithPackageAndP2PReference.staticwebassets.runtime.json");
new FileInfo(finalPath).Should().NotExist();

// GenerateStaticWebAssetsPublishManifest should generate the publish manifest file.
var intermediatePublishManifestPath = Path.Combine(intermediateOutputPath, "staticwebassets.publish.json");
new FileInfo(path).Should().Exist();
AssertManifest(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(intermediatePublishManifestPath)),
LoadPublishManifest());

AssertPublishAssets(
StaticWebAssetsManifest.FromJsonBytes(File.ReadAllBytes(intermediatePublishManifestPath)),
publishPath,
intermediateOutputPath);
}

[Fact(Skip = "https://github.com/dotnet/sdk/issues/17979")]
public void BuildProjectWithReferences_DeployOnPublish_GeneratesPublishJsonManifestAndCopiesPublishAssets()
{
Expand Down