Skip to content

Commit 730a744

Browse files
authored
Fix tests and disable scm environment variable injection (#148)
1 parent 183f476 commit 730a744

File tree

7 files changed

+73
-47
lines changed

7 files changed

+73
-47
lines changed

build/dependencies.props

+26-26
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@
44
</PropertyGroup>
55
<PropertyGroup Label="Package Versions">
66
<InternalAspNetCoreSdkPackageVersion>2.1.0-preview1-1010</InternalAspNetCoreSdkPackageVersion>
7-
<InternalAspNetCoreSiteExtensionSdkPackageVersion>2.1.0-preview2-15684</InternalAspNetCoreSiteExtensionSdkPackageVersion>
7+
<InternalAspNetCoreSiteExtensionSdkPackageVersion>2.1.0-preview1-1015</InternalAspNetCoreSiteExtensionSdkPackageVersion>
88
<MicrosoftApplicationInsightsAspNetCorePackageVersion>2.1.1</MicrosoftApplicationInsightsAspNetCorePackageVersion>
9-
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
10-
<MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>
11-
<MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>
12-
<MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>
13-
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
14-
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreHostingPackageVersion>
15-
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreMvcPackageVersion>
16-
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreRazorRuntimePackageVersion>
17-
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
18-
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview1-28193</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
19-
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreServerKestrelPackageVersion>
20-
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-28193</MicrosoftAspNetCoreTestHostPackageVersion>
9+
<MicrosoftAspNetCoreAspNetCoreModulePackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreAspNetCoreModulePackageVersion>
10+
<MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreAzureAppServicesHostingStartupPackageVersion>
11+
<MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreAzureKeyVaultHostingStartupPackageVersion>
12+
<MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreDataProtectionAzureKeyVaultPackageVersion>
13+
<MicrosoftAspNetCoreHostingAbstractionsPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreHostingAbstractionsPackageVersion>
14+
<MicrosoftAspNetCoreHostingPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreHostingPackageVersion>
15+
<MicrosoftAspNetCoreMvcPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreMvcPackageVersion>
16+
<MicrosoftAspNetCoreRazorRuntimePackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreRazorRuntimePackageVersion>
17+
<MicrosoftAspNetCoreServerIISIntegrationPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreServerIISIntegrationPackageVersion>
18+
<MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>0.5.0-preview1-28274</MicrosoftAspNetCoreServerIntegrationTestingPackageVersion>
19+
<MicrosoftAspNetCoreServerKestrelPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreServerKestrelPackageVersion>
20+
<MicrosoftAspNetCoreTestHostPackageVersion>2.1.0-preview1-28274</MicrosoftAspNetCoreTestHostPackageVersion>
2121
<MicrosoftAzureManagementFluentPackageVersion>1.1.3</MicrosoftAzureManagementFluentPackageVersion>
2222
<MicrosoftAzureServicesAppAuthenticationPackageVersion>1.1.0-preview</MicrosoftAzureServicesAppAuthenticationPackageVersion>
23-
<MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>
24-
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
25-
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
26-
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsConfigurationJsonPackageVersion>
27-
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
28-
<MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>
29-
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingConfigurationPackageVersion>
30-
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingConsolePackageVersion>
31-
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingPackageVersion>
32-
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsLoggingTestingPackageVersion>
33-
<MicrosoftExtensionsProcessSourcesPackageVersion>2.1.0-preview1-28193</MicrosoftExtensionsProcessSourcesPackageVersion>
23+
<MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationAzureKeyVaultPackageVersion>
24+
<MicrosoftExtensionsConfigurationCommandLinePackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationCommandLinePackageVersion>
25+
<MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationEnvironmentVariablesPackageVersion>
26+
<MicrosoftExtensionsConfigurationJsonPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsConfigurationJsonPackageVersion>
27+
<MicrosoftExtensionsDiagnosticAdapterPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsDiagnosticAdapterPackageVersion>
28+
<MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingAzureAppServicesPackageVersion>
29+
<MicrosoftExtensionsLoggingConfigurationPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingConfigurationPackageVersion>
30+
<MicrosoftExtensionsLoggingConsolePackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingConsolePackageVersion>
31+
<MicrosoftExtensionsLoggingPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingPackageVersion>
32+
<MicrosoftExtensionsLoggingTestingPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsLoggingTestingPackageVersion>
33+
<MicrosoftExtensionsProcessSourcesPackageVersion>2.1.0-preview1-28274</MicrosoftExtensionsProcessSourcesPackageVersion>
3434
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
35-
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview1-26122-01</MicrosoftNETCoreApp21PackageVersion>
35+
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview1-26208-06</MicrosoftNETCoreApp21PackageVersion>
3636
<MicrosoftNETTestSdkPackageVersion>15.3.0</MicrosoftNETTestSdkPackageVersion>
3737
<MicrosoftWebXdtPackageVersion>1.4.0</MicrosoftWebXdtPackageVersion>
3838
<MoqPackageVersion>4.7.49</MoqPackageVersion>
3939
<NewtonsoftJsonPackageVersion>10.0.1</NewtonsoftJsonPackageVersion>
40-
<SystemReflectionMetadataPackageVersion>1.6.0-preview1-26119-06</SystemReflectionMetadataPackageVersion>
40+
<SystemReflectionMetadataPackageVersion>1.6.0-preview1-26208-08</SystemReflectionMetadataPackageVersion>
4141
<WindowsAzureStoragePackageVersion>8.1.4</WindowsAzureStoragePackageVersion>
4242
<XunitPackageVersion>2.3.1</XunitPackageVersion>
4343
<XunitRunnerVisualStudioPackageVersion>2.3.1</XunitRunnerVisualStudioPackageVersion>

extensions/Microsoft.AspNetCore.AzureAppServices.SiteExtension/Microsoft.AspNetCore.AzureAppServices.SiteExtension.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<ItemGroup>
1616
<Content Include="applicationHost.xdt" />
17+
<Content Include="scmApplicationHost.xdt" />
1718
<Content Include="bin\$(Configuration)\$(TargetFramework)\Microsoft.Web.Xdt.Extensions.dll" PackagePath="content" />
1819
</ItemGroup>
1920

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

test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/TransformTest.cs

+38-21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension
1111
{
1212
public class TransformTest
1313
{
14+
private static readonly string XdtExtensionPath = AppDomain.CurrentDomain.BaseDirectory;
15+
1416
[Theory]
1517
[InlineData("config_empty.xml")]
1618
[InlineData("config_existingline.xml")]
@@ -24,18 +26,25 @@ public void Transform_EmptyConfig_Added(string configFile)
2426

2527
Assert.NotNull(envNode);
2628

27-
Assert.Equal(2, envNode.ChildNodes.Count);
29+
Assert.Equal(3, envNode.ChildNodes.Count);
30+
31+
var depsElement = envNode.FirstChild;
32+
Assert.Equal("add", depsElement.Name);
33+
Assert.Equal("DOTNET_ADDITIONAL_DEPS", depsElement.Attributes["name"].Value);
34+
Assert.Equal($@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;" +
35+
$@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureKeyVault.HostingStartup\;" +
36+
@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
37+
depsElement.Attributes["value"].Value);
2838

29-
var firstChild = envNode.FirstChild;
30-
Assert.Equal("add", firstChild.Name);
31-
Assert.Equal("DOTNET_ADDITIONAL_DEPS", firstChild.Attributes["name"].Value);
32-
Assert.Equal(@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
33-
firstChild.Attributes["value"].Value);
39+
var sharedStoreElement = depsElement.NextSibling;
40+
Assert.Equal("add", sharedStoreElement.Name);
41+
Assert.Equal("DOTNET_SHARED_STORE", sharedStoreElement.Attributes["name"].Value);
42+
Assert.Equal($@"{XdtExtensionPath}\store", sharedStoreElement.Attributes["value"].Value);
3443

35-
var secondChild = firstChild.NextSibling;
36-
Assert.Equal("add", secondChild.Name);
37-
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", secondChild.Attributes["name"].Value);
38-
Assert.Equal("Microsoft.AspNetCore.AzureAppServices.HostingStartup", secondChild.Attributes["value"].Value);
44+
var startupAssembliesElement = sharedStoreElement.NextSibling;
45+
Assert.Equal("add", startupAssembliesElement.Name);
46+
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", startupAssembliesElement.Attributes["name"].Value);
47+
Assert.Equal("Microsoft.AspNetCore.AzureAppServices.HostingStartup", startupAssembliesElement.Attributes["value"].Value);
3948
}
4049

4150
[Fact]
@@ -48,26 +57,34 @@ public void Transform_ExistingValue_AppendsValue()
4857

4958
Assert.NotNull(envNode);
5059

51-
Assert.Equal(2, envNode.ChildNodes.Count);
60+
Assert.Equal(3, envNode.ChildNodes.Count);
61+
62+
var depsElement = envNode.FirstChild;
63+
Assert.Equal("add", depsElement.Name);
64+
Assert.Equal("DOTNET_ADDITIONAL_DEPS", depsElement.Attributes["name"].Value);
65+
Assert.Equal(@"ExistingValue1;"+
66+
$@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\;" +
67+
$@"{XdtExtensionPath}\additionalDeps\Microsoft.AspNetCore.AzureKeyVault.HostingStartup\;" +
68+
@"%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
69+
depsElement.Attributes["value"].Value);
5270

53-
var firstChild = envNode.FirstChild;
54-
Assert.Equal("add", firstChild.Name);
55-
Assert.Equal("DOTNET_ADDITIONAL_DEPS", firstChild.Attributes["name"].Value);
56-
Assert.Equal(@"ExistingValue1;%ProgramFiles%\dotnet\additionalDeps\Microsoft.AspNetCore.AzureAppServices.HostingStartup\",
57-
firstChild.Attributes["value"].Value);
71+
var sharedStoreElement = depsElement.NextSibling;
72+
Assert.Equal("add", sharedStoreElement.Name);
73+
Assert.Equal("DOTNET_SHARED_STORE", sharedStoreElement.Attributes["name"].Value);
74+
Assert.Equal($@"ExistingValue3;{XdtExtensionPath}\store", sharedStoreElement.Attributes["value"].Value);
5875

59-
var secondChild = firstChild.NextSibling;
60-
Assert.Equal("add", secondChild.Name);
61-
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", secondChild.Attributes["name"].Value);
62-
Assert.Equal("ExistingValue2;Microsoft.AspNetCore.AzureAppServices.HostingStartup", secondChild.Attributes["value"].Value);
76+
var startupAssembliesElement = sharedStoreElement.NextSibling;
77+
Assert.Equal("add", startupAssembliesElement.Name);
78+
Assert.Equal("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", startupAssembliesElement.Attributes["name"].Value);
79+
Assert.Equal("ExistingValue2;Microsoft.AspNetCore.AzureAppServices.HostingStartup", startupAssembliesElement.Attributes["value"].Value);
6380
}
6481

6582
private static XmlDocument LoadDocAndRunTransform(string docName)
6683
{
6784
// Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionDefinition.Transform
6885
// (See Microsoft.Web.Hosting, Version=7.1.0.0) replaces variables for you in Azure.
6986
var transformFile = File.ReadAllText("applicationHost.xdt");
70-
transformFile = transformFile.Replace("%XDT_EXTENSIONPATH%", AppDomain.CurrentDomain.BaseDirectory);
87+
transformFile = transformFile.Replace("%XDT_EXTENSIONPATH%", XdtExtensionPath);
7188
var transform = new XmlTransformation(transformFile, isTransformAFile: false, logger: null);
7289
var doc = new XmlDocument();
7390
doc.Load(docName);

test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingemptyvalue.xml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<runtime>
55
<environmentVariables>
66
<add name="DOTNET_ADDITIONAL_DEPS" value="" />
7+
<add name="DOTNET_SHARED_STORE" value="" />
78
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="" />
89
</environmentVariables>
910
</runtime>

test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingline.xml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<runtime>
55
<environmentVariables>
66
<add name="DOTNET_ADDITIONAL_DEPS" />
7+
<add name="DOTNET_SHARED_STORE" />
78
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" />
89
</environmentVariables>
910
</runtime>

test/Microsoft.AspNetCore.AzureAppServices.SiteExtension.Tests/config_existingvalue.xml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<runtime>
55
<environmentVariables>
66
<add name="DOTNET_ADDITIONAL_DEPS" value="ExistingValue1" />
7+
<add name="DOTNET_SHARED_STORE" value="ExistingValue3" />
78
<add name="ASPNETCORE_HOSTINGSTARTUPASSEMBLIES" value="ExistingValue2" />
89
</environmentVariables>
910
</runtime>

0 commit comments

Comments
 (0)