@@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.AzureAppServices.SiteExtension
11
11
{
12
12
public class TransformTest
13
13
{
14
+ private static readonly string XdtExtensionPath = AppDomain . CurrentDomain . BaseDirectory ;
15
+
14
16
[ Theory ]
15
17
[ InlineData ( "config_empty.xml" ) ]
16
18
[ InlineData ( "config_existingline.xml" ) ]
@@ -24,18 +26,25 @@ public void Transform_EmptyConfig_Added(string configFile)
24
26
25
27
Assert . NotNull ( envNode ) ;
26
28
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 ) ;
28
38
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 ) ;
34
43
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 ) ;
39
48
}
40
49
41
50
[ Fact ]
@@ -48,26 +57,34 @@ public void Transform_ExistingValue_AppendsValue()
48
57
49
58
Assert . NotNull ( envNode ) ;
50
59
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 ) ;
52
70
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 ) ;
58
75
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 ) ;
63
80
}
64
81
65
82
private static XmlDocument LoadDocAndRunTransform ( string docName )
66
83
{
67
84
// Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionDefinition.Transform
68
85
// (See Microsoft.Web.Hosting, Version=7.1.0.0) replaces variables for you in Azure.
69
86
var transformFile = File . ReadAllText ( "applicationHost.xdt" ) ;
70
- transformFile = transformFile . Replace ( "%XDT_EXTENSIONPATH%" , AppDomain . CurrentDomain . BaseDirectory ) ;
87
+ transformFile = transformFile . Replace ( "%XDT_EXTENSIONPATH%" , XdtExtensionPath ) ;
71
88
var transform = new XmlTransformation ( transformFile , isTransformAFile : false , logger : null ) ;
72
89
var doc = new XmlDocument ( ) ;
73
90
doc . Load ( docName ) ;
0 commit comments