Fix tests and disable scm environment variable injection (#148)

This commit is contained in:
Pavel Krymets 2018-02-14 09:22:46 -08:00 committed by GitHub
parent 183f476492
commit 730a744dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 73 additions and 47 deletions

View File

@ -4,40 +4,40 @@
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-1010</InternalAspNetCoreSdkPackageVersion>
<InternalAspNetCoreSiteExtensionSdkPackageVersion>2.1.0-preview2-15684</InternalAspNetCoreSiteExtensionSdkPackageVersion>
<InternalAspNetCoreSiteExtensionSdkPackageVersion>2.1.0-preview1-1015</InternalAspNetCoreSiteExtensionSdkPackageVersion>
<MicrosoftApplicationInsightsAspNetCorePackageVersion>2.1.1</MicrosoftApplicationInsightsAspNetCorePackageVersion>
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
<MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>
<MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>
<MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreRazorRuntimePackageVersion>
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview1-28193</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
<MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>
<MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>
<MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreHostingPackageVersion>
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreMvcPackageVersion>
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreRazorRuntimePackageVersion>
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview1-28274</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreServerKestrelPackageVersion>
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreTestHostPackageVersion>
<MicrosoftAzureManagementFluentPackageVersion>1.1.3</MicrosoftAzureManagementFluentPackageVersion>
<MicrosoftAzureServicesAppAuthenticationPackageVersion>1.1.0-preview</MicrosoftAzureServicesAppAuthenticationPackageVersion>
<MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationJsonPackageVersion>
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
<MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingConfigurationPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsProcessSourcesPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsProcessSourcesPackageVersion>
<MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationJsonPackageVersion>
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
<MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingConfigurationPackageVersion>
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingConsolePackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingPackageVersion>
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingTestingPackageVersion>
<MicrosoftExtensionsProcessSourcesPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsProcessSourcesPackageVersion>
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview1-26122-01</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview1-26208-06</MicrosoftNETCoreApp21PackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
<MicrosoftWebXdtPackageVersion>1.4.0</MicrosoftWebXdtPackageVersion>
<MoqPackageVersion>4.7.49</MoqPackageVersion>
<NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion>
<SystemReflectionMetadataPackageVersion>1.6.0-preview1-26119-06</SystemReflectionMetadataPackageVersion>
<SystemReflectionMetadataPackageVersion>1.6.0-preview1-26208-08</SystemReflectionMetadataPackageVersion>
<WindowsAzureStoragePackageVersion>8.1.4</WindowsAzureStoragePackageVersion>
<XunitPackageVersion>2.3.1</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.3.1</XunitRunnerVisualStudioPackageVersion>

View File

@ -14,6 +14,7 @@
<ItemGroup>
<Content Include="applicationHost.xdt" />
<Content Include="scmApplicationHost.xdt" />
<Content Include="bin\$(Configuration)\$(TargetFramework)\Microsoft.Web.Xdt.Extensions.dll" PackagePath="content" />
</ItemGroup>

View File

@ -0,0 +1,5 @@
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- This file exists to prevent applicationHost.xdt from being applied to scm host that runs
other dotnet processes (dotnet build, csc etc. )-->
</configuration>

View File

@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension
{
public class TransformTest
{
private static readonly string XdtExtensionPath = AppDomain.CurrentDomain.BaseDirectory;
[Theory]
[InlineData("config_empty.xml")]
[InlineData("config_existingline.xml")]
@ -24,18 +26,25 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension
Assert.NotNull(envNode);
Assert.Equal(2, envNode.ChildNodes.Count);
Assert.Equal(3, envNode.ChildNodes.Count);
var firstChild = envNode.FirstChild;
Assert.Equal("add", firstChild.Name);
Assert.Equal("DOTNET_ADDITIONAL_DEPS", firstChild.Attributes["name"].Value);
Assert.Equal(@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
firstChild.Attributes["value"].Value);
var depsElement = envNode.FirstChild;
Assert.Equal("add", depsElement.Name);
Assert.Equal("DOTNET_ADDITIONAL_DEPS", depsElement.Attributes["name"].Value);
Assert.Equal($@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;" +
$@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureKeyVault.HostingStartup\;" +
@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
depsElement.Attributes["value"].Value);
var secondChild = firstChild.NextSibling;
Assert.Equal("add", secondChild.Name);
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", secondChild.Attributes["name"].Value);
Assert.Equal("Microsoft.AspNetCore.AzureAppServices.HostingStartup", secondChild.Attributes["value"].Value);
var sharedStoreElement = depsElement.NextSibling;
Assert.Equal("add", sharedStoreElement.Name);
Assert.Equal("DOTNET_SHARED_STORE", sharedStoreElement.Attributes["name"].Value);
Assert.Equal($@"{XdtExtensionPath}\store", sharedStoreElement.Attributes["value"].Value);
var startupAssembliesElement = sharedStoreElement.NextSibling;
Assert.Equal("add", startupAssembliesElement.Name);
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", startupAssembliesElement.Attributes["name"].Value);
Assert.Equal("Microsoft.AspNetCore.AzureAppServices.HostingStartup", startupAssembliesElement.Attributes["value"].Value);
}
[Fact]
@ -48,18 +57,26 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension
Assert.NotNull(envNode);
Assert.Equal(2, envNode.ChildNodes.Count);
Assert.Equal(3, envNode.ChildNodes.Count);
var firstChild = envNode.FirstChild;
Assert.Equal("add", firstChild.Name);
Assert.Equal("DOTNET_ADDITIONAL_DEPS", firstChild.Attributes["name"].Value);
Assert.Equal(@"ExistingValue1;%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
firstChild.Attributes["value"].Value);
var depsElement = envNode.FirstChild;
Assert.Equal("add", depsElement.Name);
Assert.Equal("DOTNET_ADDITIONAL_DEPS", depsElement.Attributes["name"].Value);
Assert.Equal(@"ExistingValue1;"+
$@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;" +
$@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureKeyVault.HostingStartup\;" +
@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
depsElement.Attributes["value"].Value);
var secondChild = firstChild.NextSibling;
Assert.Equal("add", secondChild.Name);
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", secondChild.Attributes["name"].Value);
Assert.Equal("ExistingValue2;Microsoft.AspNetCore.AzureAppServices.HostingStartup", secondChild.Attributes["value"].Value);
var sharedStoreElement = depsElement.NextSibling;
Assert.Equal("add", sharedStoreElement.Name);
Assert.Equal("DOTNET_SHARED_STORE", sharedStoreElement.Attributes["name"].Value);
Assert.Equal($@"ExistingValue3;{XdtExtensionPath}\store", sharedStoreElement.Attributes["value"].Value);
var startupAssembliesElement = sharedStoreElement.NextSibling;
Assert.Equal("add", startupAssembliesElement.Name);
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", startupAssembliesElement.Attributes["name"].Value);
Assert.Equal("ExistingValue2;Microsoft.AspNetCore.AzureAppServices.HostingStartup", startupAssembliesElement.Attributes["value"].Value);
}
private static XmlDocument LoadDocAndRunTransform(string docName)
@ -67,7 +84,7 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension
// Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionDefinition.Transform
// (See Microsoft.Web.Hosting, Version=7.1.0.0) replaces variables for you in Azure.
var transformFile = File.ReadAllText("applicationHost.xdt");
transformFile = transformFile.Replace("%XDT_EXTENSIONPATH%", AppDomain.CurrentDomain.BaseDirectory);
transformFile = transformFile.Replace("%XDT_EXTENSIONPATH%", XdtExtensionPath);
var transform = new XmlTransformation(transformFile, isTransformAFile: false, logger: null);
var doc = new XmlDocument();
doc.Load(docName);

View File

@ -4,6 +4,7 @@
<runtime>
<environmentVariables>
<add name="DOTNET_ADDITIONAL_DEPS" value="" />
<add name="DOTNET_SHARED_STORE" value="" />
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="" />
</environmentVariables>
</runtime>

View File

@ -4,6 +4,7 @@
<runtime>
<environmentVariables>
<add name="DOTNET_ADDITIONAL_DEPS" />
<add name="DOTNET_SHARED_STORE" />
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" />
</environmentVariables>
</runtime>

View File

@ -4,6 +4,7 @@
<runtime>
<environmentVariables>
<add name="DOTNET_ADDITIONAL_DEPS" value="ExistingValue1" />
<add name="DOTNET_SHARED_STORE" value="ExistingValue3" />
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="ExistingValue2" />
</environmentVariables>
</runtime>