From 362c093174d36686ded81ab7e76c3f9a729030b2 Mon Sep 17 00:00:00 2001 From: moozzyk Date: Tue, 12 Apr 2016 16:37:38 -0700 Subject: [PATCH 1/2] The web.config file needs to have Windows slashes even if published on *nix Addresses #104 --- .../WebConfigTransform.cs | 6 ++++-- .../project.json | 2 +- src/dotnet-publish-iis/WebConfigTransform.cs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs b/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs index 2b13c4249c..edfed37bb1 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs @@ -57,8 +57,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools private static void TransformAspNetCore(XElement aspNetCoreElement, string appName, bool configureForAzure) { - var appPath = Path.Combine(configureForAzure ? @"%home%\site" : ".", appName); - var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @".\logs", "stdout.log"); + // Forward slashes currently work neither in AspNetCoreModule nor in dotnet so they need to be + // replaced with backwards slashes when the application is published on a non-Windows machine + var appPath = Path.Combine(configureForAzure ? @"%home%\site" : ".", appName).Replace("/", "\\"); + var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @".\logs", "stdout.log").Replace("/", "\\"); aspNetCoreElement.SetAttributeValue("processPath", appPath); SetAttributeValueIfEmpty(aspNetCoreElement, "stdoutLogEnabled", "false"); diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/project.json b/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/project.json index 386d2cba1c..99b1acc3d5 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/project.json +++ b/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/project.json @@ -25,7 +25,7 @@ "dependencies": { "Microsoft.NETCore.App": { "type": "platform", - "version": "1.0.0-*" + "version": "1.0.0-rc2-23931" } } } diff --git a/src/dotnet-publish-iis/WebConfigTransform.cs b/src/dotnet-publish-iis/WebConfigTransform.cs index 5b5e34dec1..f25ac2b765 100644 --- a/src/dotnet-publish-iis/WebConfigTransform.cs +++ b/src/dotnet-publish-iis/WebConfigTransform.cs @@ -57,8 +57,8 @@ namespace Microsoft.AspNetCore.Tools.PublishIIS private static void TransformHttpPlatform(XElement httpPlatformElement, string appName, bool configureForAzure) { - var appPath = Path.Combine(configureForAzure ? @"%home%\site" : "..", appName); - var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @"..\logs", "stdout.log"); + var appPath = Path.Combine(configureForAzure ? @"%home%\site" : "..", appName).Replace("/", "\\"); + var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @"..\logs", "stdout.log").Replace("/", "\\"); httpPlatformElement.SetAttributeValue("processPath", appPath); SetAttributeValueIfEmpty(httpPlatformElement, "stdoutLogEnabled", "false"); From 7f7742577d4a65aebd180277d7c0790d6c2e0207 Mon Sep 17 00:00:00 2001 From: moozzyk Date: Thu, 14 Apr 2016 09:11:44 -0700 Subject: [PATCH 2/2] Removing .log extension from the log file name AspNetCoreModule appends a timestamp followed by ".log" to log file name. Removing extension prevents from creating log files with names like stdout.log.{timestamp}.log --- .../WebConfigTransform.cs | 2 +- .../WebConfigTransformFacts.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs b/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs index edfed37bb1..34d1fdc1fa 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration.Tools/WebConfigTransform.cs @@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools // Forward slashes currently work neither in AspNetCoreModule nor in dotnet so they need to be // replaced with backwards slashes when the application is published on a non-Windows machine var appPath = Path.Combine(configureForAzure ? @"%home%\site" : ".", appName).Replace("/", "\\"); - var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @".\logs", "stdout.log").Replace("/", "\\"); + var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @".\logs", "stdout").Replace("/", "\\"); aspNetCoreElement.SetAttributeValue("processPath", appPath); SetAttributeValueIfEmpty(aspNetCoreElement, "stdoutLogEnabled", "false"); diff --git a/test/Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests/WebConfigTransformFacts.cs b/test/Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests/WebConfigTransformFacts.cs index 0dbdea3839..0a86a7eef5 100644 --- a/test/Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests/WebConfigTransformFacts.cs +++ b/test/Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests/WebConfigTransformFacts.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests - + "); @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests [InlineData("aspNetCore", "stdoutLogEnabled", "true")] [InlineData("aspNetCore", "startupTimeLimit", "1200")] [InlineData("aspNetCore", "arguments", "arg1")] - [InlineData("aspNetCore", "stdoutLogFile", "logfile.log")] + [InlineData("aspNetCore", "stdoutLogFile", "logfile")] public void WebConfigTransform_wont_override_custom_values(string elementName, string attributeName, string attributeValue) { var input = WebConfigTemplate; @@ -130,7 +130,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests } Assert.Equal( - @".\logs\stdout.log", + @".\logs\stdout", (string)WebConfigTransform.Transform(input, "test.exe", configureForAzure: false) .Descendants().Attributes("stdoutLogFile").Single()); } @@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests Assert.True(XNode.DeepEquals( XDocument.Parse(@"").Root, + stdoutLogFile=""\\?\%home%\LogFiles\stdout"" startupTimeLimit=""3600""/>").Root, aspNetCoreElement)); }