Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

Commit

Permalink
Always overwrite stdoutLogPath when publishing for Azure
Browse files Browse the repository at this point in the history
Addresses #167
  • Loading branch information
moozzyk authored and moozzyk committed May 31, 2016
1 parent f45e533 commit 31a6a12
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ private static void TransformAspNetCore(XElement aspNetCoreElement, string appNa
// 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(".", appName).Replace("/", "\\");
var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @".\logs", "stdout").Replace("/", "\\");
RemoveLauncherArgs(aspNetCoreElement);

if (!isPortable)
Expand All @@ -85,7 +84,19 @@ private static void TransformAspNetCore(XElement aspNetCoreElement, string appNa
}

SetAttributeValueIfEmpty(aspNetCoreElement, "stdoutLogEnabled", "false");
SetAttributeValueIfEmpty(aspNetCoreElement, "stdoutLogFile", logPath);

var logPath = Path.Combine(configureForAzure ? @"\\?\%home%\LogFiles" : @".\logs", "stdout").Replace("/", "\\");
if (configureForAzure)
{
// When publishing for Azure we want to always overwrite path - the folder we set the path to
// will exist, the path is not easy to customize and stdoutLogPath should be only used for
// diagnostic purposes
aspNetCoreElement.SetAttributeValue("stdoutLogFile", logPath);
}
else
{
SetAttributeValueIfEmpty(aspNetCoreElement, "stdoutLogFile", logPath);
}
}

private static XElement GetOrCreateChild(XElement parent, string childName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ public void WebConfigTransform_correctly_configures_for_Azure()
aspNetCoreElement));
}

[Fact]
public void WebConfigTransform_overwrites_stdoutLogPath_for_Azure()
{
var input = WebConfigTemplate;
var output = WebConfigTransform.Transform(input, "test.exe", configureForAzure: true, isPortable: false);

Assert.Equal(
@"\\?\%home%\LogFiles\stdout",
(string)output.Descendants("aspNetCore").Single().Attribute("stdoutLogFile"));
}

[Fact]
public void WebConfigTransform_configures_portable_apps_correctly()
{
Expand Down

0 comments on commit 31a6a12

Please sign in to comment.