From d88a4195842bd98a25b207f658ce4a5c527e76b9 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 20 Jan 2021 01:17:46 -0800 Subject: [PATCH 1/7] Clean up publish of deps.json --- AspNetCore.sln | 15 ++++++ ...AspNetCore.Identity.FunctionalTests.csproj | 19 -------- .../src/GenerateMvcTestManifestTask.cs | 25 +++++++++- .../Microsoft.AspNetCore.Mvc.Testing.targets | 5 +- .../Mvc.Testing/src/WebApplicationFactory.cs | 46 +------------------ ...soft.AspNetCore.Mvc.FunctionalTests.csproj | 39 +--------------- 6 files changed, 44 insertions(+), 105 deletions(-) diff --git a/AspNetCore.sln b/AspNetCore.sln index 1954cda59cd9..374c5d92ba24 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1571,6 +1571,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Cachin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStartupInjectionAssemblyName", "src\Hosting\test\testassets\IStartupInjectionAssemblyName\IStartupInjectionAssemblyName.csproj", "{5FD94164-7D13-4618-93AD-7346B0EA0CDD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Testing.Tasks", "src\Mvc\Mvc.Testing.Tasks\src\Microsoft.AspNetCore.Mvc.Testing.Tasks.csproj", "{8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -7531,6 +7533,18 @@ Global {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x64.Build.0 = Release|Any CPU {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x86.ActiveCfg = Release|Any CPU {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x86.Build.0 = Release|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x64.ActiveCfg = Debug|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x64.Build.0 = Debug|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x86.ActiveCfg = Debug|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x86.Build.0 = Debug|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|Any CPU.Build.0 = Release|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x64.ActiveCfg = Release|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x64.Build.0 = Release|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x86.ActiveCfg = Release|Any CPU + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -8316,6 +8330,7 @@ Global {3CC4AA4E-F7E6-4BAE-B2B7-BCEC9509F68D} = {A7B8F295-AD6E-42C1-A215-17337033EBE9} {14DBB385-A1B1-49B2-A737-4DF90E127E5A} = {A7B8F295-AD6E-42C1-A215-17337033EBE9} {5FD94164-7D13-4618-93AD-7346B0EA0CDD} = {C1409A8F-555A-4A88-B803-C6D3E8B6C3B0} + {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E} = {ADAC3089-7247-4137-A8CB-8114D58C9B93} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F} diff --git a/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj b/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj index f0ca9d780b91..f796be089290 100644 --- a/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj +++ b/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj @@ -57,23 +57,4 @@ - - - <_PublishFiles Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Identity.UI\$(Configuration)\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.Identity.UI.Views.*.dll" /> - <_PublishFiles Include="$(ArtifactsBinDir)Identity.DefaultUI.WebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\Identity.DefaultUI.WebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)Identity.DefaultUI.WebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\Identity.DefaultUI.WebSite.deps.json" /> - <_wwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\testassets\Identity.DefaultUI.WebSite\wwwroot\**\*.*" /> - <_PagesFiles Include="$(MSBuildThisFileDirectory)..\..\testassets\Identity.DefaultUI.WebSite\Pages\**\*.*" /> - <_IdentityUIContent Include="$(MSBuildThisFileDirectory)..\..\UI\src\wwwroot\**\*" /> - <_IdentityUIPages Include="$(MSBuildThisFileDirectory)..\..\UI\src\Areas\Identity\Pages\**\*" /> - - - - - - - - - - diff --git a/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs b/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs index 2a945f01e212..25fce299b63f 100644 --- a/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs +++ b/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs @@ -23,6 +23,11 @@ public class GenerateMvcTestManifestTask : Task [Required] public string ManifestPath { get; set; } + /// + /// The path to copy deps files to. + /// + public string PathToCopyDeps { get; set; } + /// /// A list of content root paths and assembly names to generate the /// manifest from. @@ -40,7 +45,25 @@ public override bool Execute() { var contentRoot = project.GetMetadata("ContentRoot"); var assemblyName = project.GetMetadata("Identity"); - output[assemblyName] = contentRoot; + + // This is only set when publishing + if (string.IsNullOrEmpty(PathToCopyDeps)) + { + output[assemblyName] = contentRoot; + } + else + { + // When publishing content root is always the BaseDirectory + output[assemblyName] = "~"; + var depsFileName = $"{assemblyName}.deps.json"; + var depsPath = Path.Combine(contentRoot, depsFileName); + Log.LogMessage("Looking for " + depsPath + ": "+ File.Exists(depsPath)); + Console.WriteLine("Looking for " + depsFileName); + if (File.Exists(depsPath)) + { + File.Copy(depsPath, Path.Combine(PathToCopyDeps, depsFileName)); + } + } } var serializer = new DataContractJsonSerializer(typeof(Dictionary), new DataContractJsonSerializerSettings diff --git a/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets b/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets index 02deb7e55253..1e01403c1e52 100644 --- a/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets +++ b/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets @@ -1,4 +1,4 @@ - + <_MvcTestingTasksAssembly Condition="$(_MvcTestingTasksAssembly) == ''">$(MSBuildThisFileDirectory)..\tasks\Microsoft.AspNetCore.Mvc.Testing.dll @@ -49,7 +49,8 @@ <_PublishManifestProjects Include="%(_ContentRootProjectReferences.FusionName)"> - ~ + $([System.IO.Path]::GetDirectoryName(%(_ContentRootProjectReferences.MSBuildSourceProjectFile))) + $(PublishDir) diff --git a/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs b/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs index c75e232165fd..0f786a01d8ca 100644 --- a/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs +++ b/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs @@ -174,8 +174,7 @@ private void SetContentRoot(IWebHostBuilder builder) } var fromFile = File.Exists("MvcTestingAppManifest.json"); - var contentRoot = fromFile ? GetContentRootFromFile("MvcTestingAppManifest.json") : GetContentRootFromAssembly(); - + var contentRoot = fromFile ? GetContentRootFromFile("MvcTestingAppManifest.json") : null; if (contentRoot != null) { builder.UseContentRoot(contentRoot); @@ -199,34 +198,6 @@ private string GetContentRootFromFile(string file) return (contentRoot == "~") ? AppContext.BaseDirectory : contentRoot; } - private string GetContentRootFromAssembly() - { - var metadataAttributes = GetContentRootMetadataAttributes( - typeof(TEntryPoint).Assembly.FullName, - typeof(TEntryPoint).Assembly.GetName().Name); - - string contentRoot = null; - for (var i = 0; i < metadataAttributes.Length; i++) - { - var contentRootAttribute = metadataAttributes[i]; - var contentRootCandidate = Path.Combine( - AppContext.BaseDirectory, - contentRootAttribute.ContentRootPath); - - var contentRootMarker = Path.Combine( - contentRootCandidate, - Path.GetFileName(contentRootAttribute.ContentRootTest)); - - if (File.Exists(contentRootMarker)) - { - contentRoot = contentRootCandidate; - break; - } - } - - return contentRoot; - } - private static bool SetContentRootFromSetting(IWebHostBuilder builder) { // Attempt to look for TEST_CONTENTROOT_APPNAME in settings. This should result in looking for @@ -245,21 +216,6 @@ private static bool SetContentRootFromSetting(IWebHostBuilder builder) return true; } - private WebApplicationFactoryContentRootAttribute[] GetContentRootMetadataAttributes( - string tEntryPointAssemblyFullName, - string tEntryPointAssemblyName) - { - var testAssembly = GetTestAssemblies(); - var metadataAttributes = testAssembly - .SelectMany(a => a.GetCustomAttributes()) - .Where(a => string.Equals(a.Key, tEntryPointAssemblyFullName, StringComparison.OrdinalIgnoreCase) || - string.Equals(a.Key, tEntryPointAssemblyName, StringComparison.OrdinalIgnoreCase)) - .OrderBy(a => a.Priority) - .ToArray(); - - return metadataAttributes; - } - /// /// Gets the assemblies containing the functional tests. The /// applied to these diff --git a/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj b/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj index 4f0b137bff33..9cb3d6b02146 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj +++ b/src/Mvc/test/Mvc.FunctionalTests/Microsoft.AspNetCore.Mvc.FunctionalTests.csproj @@ -1,11 +1,8 @@ - + $(DefaultNetCoreTargetFramework) - - $(DefineConstants);GENERATE_BASELINES - $(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES Mvc.FunctionalTests false @@ -18,14 +15,6 @@ - - - - - - - @@ -59,30 +48,4 @@ - - - <_PublishFiles Include="$(ArtifactsBinDir)ApiExplorerWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ApiExplorerWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)ApplicationModelWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ApplicationModelWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)BasicWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\BasicWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)ControllersFromServicesWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ControllersFromServicesWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)CorsWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\CorsWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)ErrorPageMiddlewareWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\ErrorPageMiddlewareWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)FilesWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\FilesWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)FormatterWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\FormatterWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)GenericHostWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\GenericHostWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)HtmlGenerationWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\HtmlGenerationWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)Mvc.RoutingWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\Mvc.RoutingWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)MvcSandbox\$(Configuration)\$(DefaultNetCoreTargetFramework)\MvcSandbox.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)RazorBuildWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\RazorBuildWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)RazorPagesWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\RazorPagesWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)RazorWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\RazorWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)SecurityWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\SecurityWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)SimpleWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\SimpleWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)TagHelpersWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\TagHelpersWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)VersioningWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\VersioningWebSite.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)XmlFormattersWebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\XmlFormattersWebSite.deps.json" /> - - - - From 456b1956dc48eb71f702e9aa3a878eadde5039f4 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 20 Jan 2021 12:50:42 -0800 Subject: [PATCH 2/7] Copy over all deps files automatically --- ...hentication.AzureAD.FunctionalTests.csproj | 20 ------------------- .../src/GenerateMvcTestManifestTask.cs | 11 ++++------ .../Microsoft.AspNetCore.Mvc.Testing.targets | 4 ++-- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj b/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj index c577b2b9c7d5..d3990a60243b 100644 --- a/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj +++ b/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj @@ -20,25 +20,5 @@ - - - <_PublishFiles Include="$(ArtifactsBinDir)AzureAD.WebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\AzureAD.WebSite.deps.json" /> - - - - - - - diff --git a/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs b/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs index 25fce299b63f..0145cdb68405 100644 --- a/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs +++ b/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs @@ -40,7 +40,6 @@ public override bool Execute() { using var fileStream = File.Create(ManifestPath); var output = new Dictionary(); - foreach (var project in Projects) { var contentRoot = project.GetMetadata("ContentRoot"); @@ -55,13 +54,11 @@ public override bool Execute() { // When publishing content root is always the BaseDirectory output[assemblyName] = "~"; - var depsFileName = $"{assemblyName}.deps.json"; - var depsPath = Path.Combine(contentRoot, depsFileName); - Log.LogMessage("Looking for " + depsPath + ": "+ File.Exists(depsPath)); - Console.WriteLine("Looking for " + depsFileName); - if (File.Exists(depsPath)) + var depsFile = project.GetMetadata("DepsFile"); + Log.LogMessage("Looking for " + depsFile + ": "+ File.Exists(depsFile)); + if (File.Exists(depsFile)) { - File.Copy(depsPath, Path.Combine(PathToCopyDeps, depsFileName)); + File.Copy(depsFile, Path.Combine(PathToCopyDeps, Path.GetFileName(depsFile))); } } } diff --git a/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets b/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets index 1e01403c1e52..cd9d64e0adb7 100644 --- a/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets +++ b/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets @@ -50,11 +50,11 @@ <_PublishManifestProjects Include="%(_ContentRootProjectReferences.FusionName)"> $([System.IO.Path]::GetDirectoryName(%(_ContentRootProjectReferences.MSBuildSourceProjectFile))) - $(PublishDir) + $([System.IO.Path]::ChangeExtension('%(_ContentRootProjectReferences.Identity)', 'deps.json')) - + From e6d876ed77442a3006081f4fa72ed1b594b28411 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 20 Jan 2021 14:22:47 -0800 Subject: [PATCH 3/7] Still need non deps files --- ...ft.AspNetCore.Identity.FunctionalTests.csproj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj b/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj index f796be089290..b67e748a259d 100644 --- a/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj +++ b/src/Identity/test/Identity.FunctionalTests/Microsoft.AspNetCore.Identity.FunctionalTests.csproj @@ -57,4 +57,20 @@ + + + <_PublishFiles Include="$(ArtifactsBinDir)Microsoft.AspNetCore.Identity.UI\$(Configuration)\$(DefaultNetCoreTargetFramework)\Microsoft.AspNetCore.Identity.UI.Views.*.dll" /> + <_wwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\testassets\Identity.DefaultUI.WebSite\wwwroot\**\*.*" /> + <_PagesFiles Include="$(MSBuildThisFileDirectory)..\..\testassets\Identity.DefaultUI.WebSite\Pages\**\*.*" /> + <_IdentityUIContent Include="$(MSBuildThisFileDirectory)..\..\UI\src\wwwroot\**\*" /> + <_IdentityUIPages Include="$(MSBuildThisFileDirectory)..\..\UI\src\Areas\Identity\Pages\**\*" /> + + + + + + + + + From 69732f1c75b129d28ddac6de9673f3085f292688 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 20 Jan 2021 18:38:51 -0800 Subject: [PATCH 4/7] Update AuthSamples.FunctionalTests.csproj --- .../AuthSamples.FunctionalTests.csproj | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/src/Security/test/AuthSamples.FunctionalTests/AuthSamples.FunctionalTests.csproj b/src/Security/test/AuthSamples.FunctionalTests/AuthSamples.FunctionalTests.csproj index 1c6b96c02b1a..1a1b73d13b17 100644 --- a/src/Security/test/AuthSamples.FunctionalTests/AuthSamples.FunctionalTests.csproj +++ b/src/Security/test/AuthSamples.FunctionalTests/AuthSamples.FunctionalTests.csproj @@ -29,38 +29,4 @@ - - - - <_PublishFiles Include="$(ArtifactsBinDir)ClaimsTransformation\$(Configuration)\$(DefaultNetCoreTargetFramework)\ClaimsTransformation.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)Cookies\$(Configuration)\$(DefaultNetCoreTargetFramework)\Cookies.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)CustomAuthorizationFailureResponse\$(Configuration)\$(DefaultNetCoreTargetFramework)\CustomAuthorizationFailureResponse.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)CustomPolicyProvider\$(Configuration)\$(DefaultNetCoreTargetFramework)\CustomPolicyProvider.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)DynamicSchemes\$(Configuration)\$(DefaultNetCoreTargetFramework)\DynamicSchemes.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)Identity.ExternalClaims\$(Configuration)\$(DefaultNetCoreTargetFramework)\Identity.ExternalClaims.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)PathSchemeSelection\$(Configuration)\$(DefaultNetCoreTargetFramework)\PathSchemeSelection.deps.json" /> - <_PublishFiles Include="$(ArtifactsBinDir)StaticFilesAuth\$(Configuration)\$(DefaultNetCoreTargetFramework)\StaticFilesAuth.deps.json" /> - <_claimsWwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\samples\ClaimsTransformation\wwwroot\**\*.*" /> - <_cookiesWwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\samples\Cookies\wwwroot\**\*.*" /> - <_customAuthorizationFailureResponseFiles Include="$(MSBuildThisFileDirectory)..\..\samples\CustomAuthorizationFailureResponse\**\*.*" /> - <_customProviderFiles Include="$(MSBuildThisFileDirectory)..\..\samples\CustomPolicyProvider\**\*.*" /> - <_schemesWwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\samples\DynamicSchemes\wwwroot\**\*.*" /> - <_identityWwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\samples\Identity.ExternalClaims\wwwroot\**\*.*" /> - <_pathWwwrootFiles Include="$(MSBuildThisFileDirectory)..\..\samples\PathSchemeSelection\wwwroot\**\*.*" /> - <_staticFiles Include="$(MSBuildThisFileDirectory)..\..\samples\StaticFilesAuth\**\*.*" /> - - - - - - - - - - - - - - - From 048cbc307e40f8f0874a50b93185ce69fc412223 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 21 Jan 2021 08:58:15 -0800 Subject: [PATCH 5/7] Add back code --- .../Mvc.Testing/src/WebApplicationFactory.cs | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs b/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs index 0f786a01d8ca..68dd8da68308 100644 --- a/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs +++ b/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs @@ -174,7 +174,7 @@ private void SetContentRoot(IWebHostBuilder builder) } var fromFile = File.Exists("MvcTestingAppManifest.json"); - var contentRoot = fromFile ? GetContentRootFromFile("MvcTestingAppManifest.json") : null; + var contentRoot = fromFile ? GetContentRootFromFile("MvcTestingAppManifest.json") : GetContentRootFromAssembly(); if (contentRoot != null) { builder.UseContentRoot(contentRoot); @@ -197,7 +197,35 @@ private string GetContentRootFromFile(string file) return (contentRoot == "~") ? AppContext.BaseDirectory : contentRoot; } - + + private string GetContentRootFromAssembly() + { + var metadataAttributes = GetContentRootMetadataAttributes( + typeof(TEntryPoint).Assembly.FullName, + typeof(TEntryPoint).Assembly.GetName().Name); + + string contentRoot = null; + for (var i = 0; i < metadataAttributes.Length; i++) + { + var contentRootAttribute = metadataAttributes[i]; + var contentRootCandidate = Path.Combine( + AppContext.BaseDirectory, + contentRootAttribute.ContentRootPath); + + var contentRootMarker = Path.Combine( + contentRootCandidate, + Path.GetFileName(contentRootAttribute.ContentRootTest)); + + if (File.Exists(contentRootMarker)) + { + contentRoot = contentRootCandidate; + break; + } + } + + return contentRoot; + } + private static bool SetContentRootFromSetting(IWebHostBuilder builder) { // Attempt to look for TEST_CONTENTROOT_APPNAME in settings. This should result in looking for @@ -216,6 +244,21 @@ private static bool SetContentRootFromSetting(IWebHostBuilder builder) return true; } + private WebApplicationFactoryContentRootAttribute[] GetContentRootMetadataAttributes( + string tEntryPointAssemblyFullName, + string tEntryPointAssemblyName) + { + var testAssembly = GetTestAssemblies(); + var metadataAttributes = testAssembly + .SelectMany(a => a.GetCustomAttributes()) + .Where(a => string.Equals(a.Key, tEntryPointAssemblyFullName, StringComparison.OrdinalIgnoreCase) || + string.Equals(a.Key, tEntryPointAssemblyName, StringComparison.OrdinalIgnoreCase)) + .OrderBy(a => a.Priority) + .ToArray(); + + return metadataAttributes; + } + /// /// Gets the assemblies containing the functional tests. The /// applied to these From dadf5a42f515fffd668adc8f3d1cd097d03ddb7a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 21 Jan 2021 09:14:20 -0800 Subject: [PATCH 6/7] Cleanup --- AspNetCore.sln | 15 ---- .../Mvc.Testing/src/WebApplicationFactory.cs | 87 ++++++++++--------- src/Mvc/Mvc.slnf | 1 + src/Mvc/MvcNoDeps.slnf | 1 + 4 files changed, 46 insertions(+), 58 deletions(-) diff --git a/AspNetCore.sln b/AspNetCore.sln index 374c5d92ba24..1954cda59cd9 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1571,8 +1571,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Cachin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStartupInjectionAssemblyName", "src\Hosting\test\testassets\IStartupInjectionAssemblyName\IStartupInjectionAssemblyName.csproj", "{5FD94164-7D13-4618-93AD-7346B0EA0CDD}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Testing.Tasks", "src\Mvc\Mvc.Testing.Tasks\src\Microsoft.AspNetCore.Mvc.Testing.Tasks.csproj", "{8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -7533,18 +7531,6 @@ Global {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x64.Build.0 = Release|Any CPU {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x86.ActiveCfg = Release|Any CPU {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x86.Build.0 = Release|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x64.ActiveCfg = Debug|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x64.Build.0 = Debug|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x86.ActiveCfg = Debug|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Debug|x86.Build.0 = Debug|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|Any CPU.Build.0 = Release|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x64.ActiveCfg = Release|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x64.Build.0 = Release|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x86.ActiveCfg = Release|Any CPU - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -8330,7 +8316,6 @@ Global {3CC4AA4E-F7E6-4BAE-B2B7-BCEC9509F68D} = {A7B8F295-AD6E-42C1-A215-17337033EBE9} {14DBB385-A1B1-49B2-A737-4DF90E127E5A} = {A7B8F295-AD6E-42C1-A215-17337033EBE9} {5FD94164-7D13-4618-93AD-7346B0EA0CDD} = {C1409A8F-555A-4A88-B803-C6D3E8B6C3B0} - {8EFB7A13-54EB-4008-9B3E-42BDADB6C12E} = {ADAC3089-7247-4137-A8CB-8114D58C9B93} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F} diff --git a/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs b/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs index 68dd8da68308..9a505687d518 100644 --- a/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs +++ b/src/Mvc/Mvc.Testing/src/WebApplicationFactory.cs @@ -175,6 +175,7 @@ private void SetContentRoot(IWebHostBuilder builder) var fromFile = File.Exists("MvcTestingAppManifest.json"); var contentRoot = fromFile ? GetContentRootFromFile("MvcTestingAppManifest.json") : GetContentRootFromAssembly(); + if (contentRoot != null) { builder.UseContentRoot(contentRoot); @@ -189,43 +190,43 @@ private string GetContentRootFromFile(string file) { var data = JsonSerializer.Deserialize>(File.ReadAllBytes(file)); var key = typeof(TEntryPoint).Assembly.GetName().FullName; - + if (!data.TryGetValue(key, out var contentRoot)) { - throw new KeyNotFoundException($"Could not find content root for project '{key}' in test manifest file '{file}'"); + throw new KeyNotFoundException($"Could not find content root for project '{key}' in test manifest file '{file}'"); } return (contentRoot == "~") ? AppContext.BaseDirectory : contentRoot; } - + private string GetContentRootFromAssembly() - { - var metadataAttributes = GetContentRootMetadataAttributes( - typeof(TEntryPoint).Assembly.FullName, - typeof(TEntryPoint).Assembly.GetName().Name); - - string contentRoot = null; - for (var i = 0; i < metadataAttributes.Length; i++) - { - var contentRootAttribute = metadataAttributes[i]; - var contentRootCandidate = Path.Combine( - AppContext.BaseDirectory, - contentRootAttribute.ContentRootPath); - - var contentRootMarker = Path.Combine( - contentRootCandidate, - Path.GetFileName(contentRootAttribute.ContentRootTest)); - - if (File.Exists(contentRootMarker)) - { - contentRoot = contentRootCandidate; - break; - } - } - - return contentRoot; + { + var metadataAttributes = GetContentRootMetadataAttributes( + typeof(TEntryPoint).Assembly.FullName, + typeof(TEntryPoint).Assembly.GetName().Name); + + string contentRoot = null; + for (var i = 0; i < metadataAttributes.Length; i++) + { + var contentRootAttribute = metadataAttributes[i]; + var contentRootCandidate = Path.Combine( + AppContext.BaseDirectory, + contentRootAttribute.ContentRootPath); + + var contentRootMarker = Path.Combine( + contentRootCandidate, + Path.GetFileName(contentRootAttribute.ContentRootTest)); + + if (File.Exists(contentRootMarker)) + { + contentRoot = contentRootCandidate; + break; + } + } + + return contentRoot; } - + private static bool SetContentRootFromSetting(IWebHostBuilder builder) { // Attempt to look for TEST_CONTENTROOT_APPNAME in settings. This should result in looking for @@ -244,21 +245,21 @@ private static bool SetContentRootFromSetting(IWebHostBuilder builder) return true; } - private WebApplicationFactoryContentRootAttribute[] GetContentRootMetadataAttributes( - string tEntryPointAssemblyFullName, - string tEntryPointAssemblyName) - { - var testAssembly = GetTestAssemblies(); - var metadataAttributes = testAssembly - .SelectMany(a => a.GetCustomAttributes()) - .Where(a => string.Equals(a.Key, tEntryPointAssemblyFullName, StringComparison.OrdinalIgnoreCase) || - string.Equals(a.Key, tEntryPointAssemblyName, StringComparison.OrdinalIgnoreCase)) - .OrderBy(a => a.Priority) - .ToArray(); - - return metadataAttributes; + private WebApplicationFactoryContentRootAttribute[] GetContentRootMetadataAttributes( + string tEntryPointAssemblyFullName, + string tEntryPointAssemblyName) + { + var testAssembly = GetTestAssemblies(); + var metadataAttributes = testAssembly + .SelectMany(a => a.GetCustomAttributes()) + .Where(a => string.Equals(a.Key, tEntryPointAssemblyFullName, StringComparison.OrdinalIgnoreCase) || + string.Equals(a.Key, tEntryPointAssemblyName, StringComparison.OrdinalIgnoreCase)) + .OrderBy(a => a.Priority) + .ToArray(); + + return metadataAttributes; } - + /// /// Gets the assemblies containing the functional tests. The /// applied to these diff --git a/src/Mvc/Mvc.slnf b/src/Mvc/Mvc.slnf index 5ebe7d5d3090..be3eed0e58cc 100644 --- a/src/Mvc/Mvc.slnf +++ b/src/Mvc/Mvc.slnf @@ -106,6 +106,7 @@ "src\\Mvc\\test\\Mvc.IntegrationTests\\Microsoft.AspNetCore.Mvc.IntegrationTests.csproj", "src\\Mvc\\shared\\Mvc.TestDiagnosticListener\\Microsoft.AspNetCore.Mvc.TestDiagnosticListener.csproj", "src\\Mvc\\Mvc.Testing\\src\\Microsoft.AspNetCore.Mvc.Testing.csproj", + "src\\Mvc\\Mvc.Testing.Tasks\\src\\Microsoft.AspNetCore.Mvc.Testing.Tasks.csproj", "src\\Mvc\\shared\\Mvc.Core.TestCommon\\Microsoft.AspNetCore.Mvc.Core.TestCommon.csproj", "src\\Mvc\\Mvc.NewtonsoftJson\\src\\Microsoft.AspNetCore.Mvc.NewtonsoftJson.csproj", "src\\Mvc\\Mvc.NewtonsoftJson\\test\\Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test.csproj", diff --git a/src/Mvc/MvcNoDeps.slnf b/src/Mvc/MvcNoDeps.slnf index e8357e970929..6160127d9ed6 100644 --- a/src/Mvc/MvcNoDeps.slnf +++ b/src/Mvc/MvcNoDeps.slnf @@ -32,6 +32,7 @@ "src\\Mvc\\Mvc.TagHelpers\\src\\Microsoft.AspNetCore.Mvc.TagHelpers.csproj", "src\\Mvc\\Mvc.TagHelpers\\test\\Microsoft.AspNetCore.Mvc.TagHelpers.Test.csproj", "src\\Mvc\\Mvc.Testing\\src\\Microsoft.AspNetCore.Mvc.Testing.csproj", + "src\\Mvc\\Mvc.Testing.Tasks\\src\\Microsoft.AspNetCore.Mvc.Testing.Tasks.csproj", "src\\Mvc\\Mvc.ViewFeatures\\src\\Microsoft.AspNetCore.Mvc.ViewFeatures.csproj", "src\\Mvc\\Mvc.ViewFeatures\\test\\Microsoft.AspNetCore.Mvc.ViewFeatures.Test.csproj", "src\\Mvc\\Mvc\\src\\Microsoft.AspNetCore.Mvc.csproj", From 90fe4f8a3180be4f4f3146624327e530c5edbb65 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 21 Jan 2021 10:12:42 -0800 Subject: [PATCH 7/7] Do deps copy in target instead --- AspNetCore.sln | 18 +++++++++++++++ .../src/GenerateMvcTestManifestTask.cs | 23 +------------------ .../Microsoft.AspNetCore.Mvc.Testing.targets | 7 +++--- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/AspNetCore.sln b/AspNetCore.sln index 1954cda59cd9..cb57b2b89125 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -1571,6 +1571,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Cachin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStartupInjectionAssemblyName", "src\Hosting\test\testassets\IStartupInjectionAssemblyName\IStartupInjectionAssemblyName.csproj", "{5FD94164-7D13-4618-93AD-7346B0EA0CDD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Testing.Tasks", "src\Mvc\Mvc.Testing.Tasks\src\Microsoft.AspNetCore.Mvc.Testing.Tasks.csproj", "{5C50FA92-5488-4470-B42E-48EFEBA51D5A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mvc.Testing.Tasks", "Mvc.Testing.Tasks", "{34465A80-3BAF-4059-81B3-9090C0DB598F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -7531,6 +7535,18 @@ Global {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x64.Build.0 = Release|Any CPU {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x86.ActiveCfg = Release|Any CPU {5FD94164-7D13-4618-93AD-7346B0EA0CDD}.Release|x86.Build.0 = Release|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Debug|x64.ActiveCfg = Debug|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Debug|x64.Build.0 = Debug|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Debug|x86.ActiveCfg = Debug|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Debug|x86.Build.0 = Debug|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Release|Any CPU.Build.0 = Release|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Release|x64.ActiveCfg = Release|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Release|x64.Build.0 = Release|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Release|x86.ActiveCfg = Release|Any CPU + {5C50FA92-5488-4470-B42E-48EFEBA51D5A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -8316,6 +8332,8 @@ Global {3CC4AA4E-F7E6-4BAE-B2B7-BCEC9509F68D} = {A7B8F295-AD6E-42C1-A215-17337033EBE9} {14DBB385-A1B1-49B2-A737-4DF90E127E5A} = {A7B8F295-AD6E-42C1-A215-17337033EBE9} {5FD94164-7D13-4618-93AD-7346B0EA0CDD} = {C1409A8F-555A-4A88-B803-C6D3E8B6C3B0} + {5C50FA92-5488-4470-B42E-48EFEBA51D5A} = {34465A80-3BAF-4059-81B3-9090C0DB598F} + {34465A80-3BAF-4059-81B3-9090C0DB598F} = {1A0EFF9F-E699-4303-AE50-BFAF9804EEB6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F} diff --git a/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs b/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs index 0145cdb68405..505b8eb5e336 100644 --- a/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs +++ b/src/Mvc/Mvc.Testing.Tasks/src/GenerateMvcTestManifestTask.cs @@ -23,11 +23,6 @@ public class GenerateMvcTestManifestTask : Task [Required] public string ManifestPath { get; set; } - /// - /// The path to copy deps files to. - /// - public string PathToCopyDeps { get; set; } - /// /// A list of content root paths and assembly names to generate the /// manifest from. @@ -44,23 +39,7 @@ public override bool Execute() { var contentRoot = project.GetMetadata("ContentRoot"); var assemblyName = project.GetMetadata("Identity"); - - // This is only set when publishing - if (string.IsNullOrEmpty(PathToCopyDeps)) - { - output[assemblyName] = contentRoot; - } - else - { - // When publishing content root is always the BaseDirectory - output[assemblyName] = "~"; - var depsFile = project.GetMetadata("DepsFile"); - Log.LogMessage("Looking for " + depsFile + ": "+ File.Exists(depsFile)); - if (File.Exists(depsFile)) - { - File.Copy(depsFile, Path.Combine(PathToCopyDeps, Path.GetFileName(depsFile))); - } - } + output[assemblyName] = contentRoot; } var serializer = new DataContractJsonSerializer(typeof(Dictionary), new DataContractJsonSerializerSettings diff --git a/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets b/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets index cd9d64e0adb7..561fa5260f5a 100644 --- a/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets +++ b/src/Mvc/Mvc.Testing/src/Microsoft.AspNetCore.Mvc.Testing.targets @@ -49,12 +49,13 @@ <_PublishManifestProjects Include="%(_ContentRootProjectReferences.FusionName)"> - $([System.IO.Path]::GetDirectoryName(%(_ContentRootProjectReferences.MSBuildSourceProjectFile))) - $([System.IO.Path]::ChangeExtension('%(_ContentRootProjectReferences.Identity)', 'deps.json')) + ~ + <_DepsFileToPublish Include="$([System.IO.Path]::ChangeExtension('%(_ContentRootProjectReferences.Identity)', 'deps.json'))" /> - + +