@@ -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 ) ;
0 commit comments