Copy ANCM into a separate folder to avoid copy races (#12103)

This commit is contained in:
Justin Kotalik 2019-07-16 13:34:06 -07:00 committed by GitHub
parent 79823c7b9a
commit 71d39e59d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
internal static string HostableWebCoreLocation => Environment.ExpandEnvironmentVariables($@"%windir%\system32\inetsrv\{HWebCoreDll}");
internal static string BasePath => Path.Combine(Path.GetDirectoryName(new Uri(typeof(TestServer).Assembly.CodeBase).AbsolutePath),
"ANCM",
Environment.Is64BitProcess ? "x64" : "x86");
internal static string AspNetCoreModuleLocation => Path.Combine(BasePath, AspNetCoreModuleDll);

View File

@ -85,7 +85,11 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
protected string GetAncmLocation()
{
var ancmDllName = "aspnetcorev2.dll";
var arch = DeploymentParameters.RuntimeArchitecture == RuntimeArchitecture.x64 ? $@"x64\{ancmDllName}" : $@"x86\{ancmDllName}";
// There are issues with having multiple dlls copy to the same location in both build and publish
// It's inherently racy. Therefore, we have two different copy locations and when trying verify backwards compat tests,
// we select the version of ANCM in a different folder.
var basePath = File.Exists(Path.Combine(AppContext.BaseDirectory, "x64", "aspnetcorev2.dll")) ? "" : @"ANCM\";
var arch = DeploymentParameters.RuntimeArchitecture == RuntimeArchitecture.x64 ? $@"{basePath}x64\{ancmDllName}" : $@"{basePath}x86\{ancmDllName}";
var ancmFile = Path.Combine(AppContext.BaseDirectory, arch);
if (!File.Exists(Environment.ExpandEnvironmentVariables(ancmFile)))
{

View File

@ -44,7 +44,7 @@
<Target Name="AddRunNativeComponents" BeforeTargets="AssignTargetPaths" Condition="'$(BuildIisNativeProjects)' == 'true'">
<ItemGroup>
<None Include="%(ShimComponents.DllLocation)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Link="%(ShimComponents.Platform)\%(ShimComponents.PackageSubPath)\%(ShimComponents.NativeAsset).dll" />
<None Include="%(ShimComponents.DllLocation)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" Link="ANCM\%(ShimComponents.Platform)\%(ShimComponents.PackageSubPath)\%(ShimComponents.NativeAsset).dll" />
</ItemGroup>
</Target>