Merge pull request dotnet/aspnetcore-tooling#1442 from dotnet/javiercn/swa-publish-no-build

[StaticWebAssets][Fixes #AspNetCore/17426] Publish no build doesn't copy static web assets from referenced projects\n\nCommit migrated from 45a6c10276
This commit is contained in:
Artak 2020-01-14 18:46:50 -08:00 committed by GitHub
commit c2cfbc87ab
2 changed files with 28 additions and 12 deletions

View File

@ -54,23 +54,19 @@ Copyright (c) .NET Foundation. All rights reserved.
$(GetCurrentProjectStaticWebAssetsDependsOn) $(GetCurrentProjectStaticWebAssetsDependsOn)
</GetCurrentProjectStaticWebAssetsDependsOn> </GetCurrentProjectStaticWebAssetsDependsOn>
<AssignTargetPathsDependsOn> <GetCopyToOutputDirectoryItemsDependsOn>
$(GetCopyToOutputDirectoryItemsDependsOn);
GenerateStaticWebAssetsManifest; GenerateStaticWebAssetsManifest;
$(AssignTargetPathsDependsOn) </GetCopyToOutputDirectoryItemsDependsOn>
</AssignTargetPathsDependsOn>
<ResolveStaticWebAssetsInputsDependsOn> <ResolveStaticWebAssetsInputsDependsOn>
ResolveCurrentProjectStaticWebAssetsInputs; ResolveCurrentProjectStaticWebAssetsInputs;
$(ResolveStaticWebAssetsInputsDependsOn)
</ResolveStaticWebAssetsInputsDependsOn>
<ResolveStaticWebAssetsInputsDependsOn Condition="$(NoBuild) != 'true'">
ResolveReferencedProjectsStaticWebAssets; ResolveReferencedProjectsStaticWebAssets;
$(ResolveStaticWebAssetsInputsDependsOn) $(ResolveStaticWebAssetsInputsDependsOn)
</ResolveStaticWebAssetsInputsDependsOn> </ResolveStaticWebAssetsInputsDependsOn>
<ResolveReferencedProjectsStaticWebAssetsDependsOn> <ResolveReferencedProjectsStaticWebAssetsDependsOn>
ResolveReferences; PrepareProjectReferences;
$(ResolveReferencedProjectsStaticWebAssetsDependsOn) $(ResolveReferencedProjectsStaticWebAssetsDependsOn)
</ResolveReferencedProjectsStaticWebAssetsDependsOn> </ResolveReferencedProjectsStaticWebAssetsDependsOn>
@ -187,14 +183,14 @@ Copyright (c) .NET Foundation. All rights reserved.
<!-- This is the list of inputs that will be used for generating the manifest used during development. --> <!-- This is the list of inputs that will be used for generating the manifest used during development. -->
<ItemGroup> <ItemGroup>
<Content <ContentWithTargetPath
Include="$(_GeneratedStaticWebAssetsDevelopmentManifest)" Include="$(_GeneratedStaticWebAssetsDevelopmentManifest)"
Condition="'@(_ExternalStaticWebAsset->Count())' != '0'" Condition="'@(_ExternalStaticWebAsset->Count())' != '0'">
Link="$(TargetName).StaticWebAssets.xml">
<TargetPath>$(TargetName).StaticWebAssets.xml</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory> <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content> </ContentWithTargetPath>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -129,6 +129,26 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryTransitiveDependency", "js", "pkg-transitive-dep.js")); Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryTransitiveDependency", "js", "pkg-transitive-dep.js"));
} }
[Fact]
[InitializeTestProject("AppWithPackageAndP2PReference", additionalProjects: new[] { "ClassLibrary", "ClassLibrary2" })]
public async Task Publish_NoBuild_CopiesStaticWebAssetsToDestinationFolder()
{
var build = await DotnetMSBuild("Build", "/restore");
Assert.BuildPassed(build);
var publish = await DotnetMSBuild("Publish", "/p:NoBuild=true");
Assert.BuildPassed(publish);
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary", "js", "project-transitive-dep.js"));
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary", "js", "project-transitive-dep.v4.js"));
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary2", "css", "site.css"));
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "ClassLibrary2", "js", "project-direct-dep.js"));
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryDirectDependency", "css", "site.css"));
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryDirectDependency", "js", "pkg-direct-dep.js"));
Assert.FileExists(publish, PublishOutputPath, Path.Combine("wwwroot", "_content", "PackageLibraryTransitiveDependency", "js", "pkg-transitive-dep.js"));
}
[Fact] [Fact]
[InitializeTestProject("SimpleMvc")] [InitializeTestProject("SimpleMvc")]