parent
877b1fd42c
commit
f58641be49
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
||||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
|||
};
|
||||
app.HelpOption("-h|--help");
|
||||
|
||||
var publishFolderOption = app.Option("--publish-folder|-p", "The path to the publish output folder", CommandOptionType.SingleValue);
|
||||
var publishFolderOption = app.Option("-p|--publish-folder", "The path to the publish output folder", CommandOptionType.SingleValue);
|
||||
var frameworkOption = app.Option("-f|--framework <FRAMEWORK>", "Target framework of application being published", CommandOptionType.SingleValue);
|
||||
var configurationOption = app.Option("-c|--configuration <CONFIGURATION>", "Target configuration of application being published", CommandOptionType.SingleValue);
|
||||
var projectPath = app.Argument("<PROJECT>", "The path to the project (project folder or project.json) being published. If empty the current directory is used.");
|
||||
|
||||
app.OnExecute(() =>
|
||||
|
|
@ -36,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
|||
|
||||
Reporter.Output.WriteLine($"Configuring the following project for use with IIS: '{publishFolder}'");
|
||||
|
||||
var exitCode = new PublishIISCommand(publishFolder, framework, projectPath.Value).Run();
|
||||
var exitCode = new PublishIISCommand(publishFolder, framework, configurationOption.Value(), projectPath.Value).Run();
|
||||
|
||||
Reporter.Output.WriteLine("Configuring project completed successfully");
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
|||
private readonly string _publishFolder;
|
||||
private readonly string _projectPath;
|
||||
private readonly string _framework;
|
||||
private readonly string _configuration;
|
||||
|
||||
public PublishIISCommand(string publishFolder, string framework, string projectPath)
|
||||
public PublishIISCommand(string publishFolder, string framework, string configuration, string projectPath)
|
||||
{
|
||||
_publishFolder = publishFolder;
|
||||
_projectPath = projectPath;
|
||||
_framework = framework;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public int Run()
|
||||
|
|
@ -48,7 +50,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
|||
|
||||
var projectContext = GetProjectContext(applicationBasePath, _framework);
|
||||
var isPortable = !projectContext.TargetFramework.IsDesktop() && projectContext.IsPortable;
|
||||
var applicationName = projectContext.ProjectFile.Name + (isPortable ? ".dll" : ".exe");
|
||||
var applicationName =
|
||||
projectContext.ProjectFile.GetCompilerOptions(projectContext.TargetFramework, _configuration).OutputName +
|
||||
(isPortable ? ".dll" : ".exe");
|
||||
var transformedConfig = WebConfigTransform.Transform(webConfigXml, applicationName, ConfigureForAzure(), isPortable);
|
||||
|
||||
using (var f = new FileStream(webConfigPath, FileMode.Create))
|
||||
|
|
|
|||
|
|
@ -14,5 +14,8 @@
|
|||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
|||
{
|
||||
var folders = CreateTestDir($@"{{ ""frameworks"": {{ ""{targetFramework}"": {{ }} }} }}");
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, targetFramework, folders.ProjectPath).Run();
|
||||
new PublishIISCommand(folders.PublishOutput, targetFramework, null, folders.ProjectPath).Run();
|
||||
|
||||
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||
.Descendants("aspNetCore").Attributes("processPath").Single();
|
||||
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
|||
}
|
||||
}");
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", folders.ProjectPath).Run();
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", null, folders.ProjectPath).Run();
|
||||
|
||||
var aspNetCoreElement = GetPublishedWebConfig(folders.PublishOutput)
|
||||
.Descendants("aspNetCore").Single();
|
||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
|||
{
|
||||
var folders = CreateTestDir($@"{{ ""name"": ""{projectName}"", ""frameworks"": {{ ""netcoreapp1.0"": {{}} }} }}");
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", folders.ProjectPath).Run();
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", null, folders.ProjectPath).Run();
|
||||
|
||||
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||
.Descendants("aspNetCore").Attributes("processPath").Single();
|
||||
|
|
@ -78,6 +78,48 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
|||
Directory.Delete(folders.TestRoot, recursive: true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PublishIIS_reads_application_name_from_outputName_if_specified()
|
||||
{
|
||||
var folders = CreateTestDir(
|
||||
@"{
|
||||
""name"": ""awesomeApp"",
|
||||
""buildOptions"": { ""outputName"": ""myApp"" },
|
||||
""frameworks"": { ""netcoreapp1.0"": { } }
|
||||
}");
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", null, folders.ProjectPath).Run();
|
||||
|
||||
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||
.Descendants("aspNetCore").Attributes("processPath").Single();
|
||||
|
||||
Assert.Equal(@".\myApp.exe", processPath);
|
||||
|
||||
Directory.Delete(folders.TestRoot, recursive: true);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Debug", "myApp")]
|
||||
[InlineData("Release", "awesomeApp")]
|
||||
public void PublishIIS_reads_application_name_from_configuration_specific_outputName_if_specified(string configuration, string expectedName)
|
||||
{
|
||||
var folders = CreateTestDir(
|
||||
@"{
|
||||
""name"": ""awesomeApp"",
|
||||
""configurations"": { ""Debug"": { ""buildOptions"": { ""outputName"": ""myApp"" } } },
|
||||
""frameworks"": { ""netcoreapp1.0"": { } }
|
||||
}");
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", configuration, folders.ProjectPath).Run();
|
||||
|
||||
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||
.Descendants("aspNetCore").Attributes("processPath").Single();
|
||||
|
||||
Assert.Equal($@".\{expectedName}.exe", processPath);
|
||||
|
||||
Directory.Delete(folders.TestRoot, recursive: true);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("projectDir")]
|
||||
[InlineData("project.Dir")]
|
||||
|
|
@ -85,7 +127,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
|||
{
|
||||
var folders = CreateTestDir(@"{ ""frameworks"": { ""netcoreapp1.0"": { } } }", projectDir);
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0",
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", null,
|
||||
Path.Combine(folders.ProjectPath, "project.json")).Run();
|
||||
|
||||
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||
|
|
@ -111,7 +153,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
|||
</system.webServer>
|
||||
</configuration>");
|
||||
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0",
|
||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", null,
|
||||
Path.Combine(folders.ProjectPath, "project.json")).Run();
|
||||
|
||||
var aspNetCoreElement = GetPublishedWebConfig(folders.PublishOutput)
|
||||
|
|
|
|||
Loading…
Reference in New Issue