parent
877b1fd42c
commit
f58641be49
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<packageSources>
|
<packageSources>
|
||||||
|
<clear />
|
||||||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
|
<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" />
|
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
||||||
};
|
};
|
||||||
app.HelpOption("-h|--help");
|
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 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.");
|
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(() =>
|
app.OnExecute(() =>
|
||||||
|
|
@ -36,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
||||||
|
|
||||||
Reporter.Output.WriteLine($"Configuring the following project for use with IIS: '{publishFolder}'");
|
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");
|
Reporter.Output.WriteLine("Configuring project completed successfully");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,14 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
||||||
private readonly string _publishFolder;
|
private readonly string _publishFolder;
|
||||||
private readonly string _projectPath;
|
private readonly string _projectPath;
|
||||||
private readonly string _framework;
|
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;
|
_publishFolder = publishFolder;
|
||||||
_projectPath = projectPath;
|
_projectPath = projectPath;
|
||||||
_framework = framework;
|
_framework = framework;
|
||||||
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Run()
|
public int Run()
|
||||||
|
|
@ -48,7 +50,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools
|
||||||
|
|
||||||
var projectContext = GetProjectContext(applicationBasePath, _framework);
|
var projectContext = GetProjectContext(applicationBasePath, _framework);
|
||||||
var isPortable = !projectContext.TargetFramework.IsDesktop() && projectContext.IsPortable;
|
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);
|
var transformedConfig = WebConfigTransform.Transform(webConfigXml, applicationName, ConfigureForAzure(), isPortable);
|
||||||
|
|
||||||
using (var f = new FileStream(webConfigPath, FileMode.Create))
|
using (var f = new FileStream(webConfigPath, FileMode.Create))
|
||||||
|
|
|
||||||
|
|
@ -14,5 +14,8 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
||||||
{
|
{
|
||||||
var folders = CreateTestDir($@"{{ ""frameworks"": {{ ""{targetFramework}"": {{ }} }} }}");
|
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)
|
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||||
.Descendants("aspNetCore").Attributes("processPath").Single();
|
.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)
|
var aspNetCoreElement = GetPublishedWebConfig(folders.PublishOutput)
|
||||||
.Descendants("aspNetCore").Single();
|
.Descendants("aspNetCore").Single();
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
||||||
{
|
{
|
||||||
var folders = CreateTestDir($@"{{ ""name"": ""{projectName}"", ""frameworks"": {{ ""netcoreapp1.0"": {{}} }} }}");
|
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)
|
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||||
.Descendants("aspNetCore").Attributes("processPath").Single();
|
.Descendants("aspNetCore").Attributes("processPath").Single();
|
||||||
|
|
@ -78,6 +78,48 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
||||||
Directory.Delete(folders.TestRoot, recursive: true);
|
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]
|
[Theory]
|
||||||
[InlineData("projectDir")]
|
[InlineData("projectDir")]
|
||||||
[InlineData("project.Dir")]
|
[InlineData("project.Dir")]
|
||||||
|
|
@ -85,7 +127,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
||||||
{
|
{
|
||||||
var folders = CreateTestDir(@"{ ""frameworks"": { ""netcoreapp1.0"": { } } }", projectDir);
|
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();
|
Path.Combine(folders.ProjectPath, "project.json")).Run();
|
||||||
|
|
||||||
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
var processPath = (string)GetPublishedWebConfig(folders.PublishOutput)
|
||||||
|
|
@ -111,7 +153,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.Tools.Tests
|
||||||
</system.webServer>
|
</system.webServer>
|
||||||
</configuration>");
|
</configuration>");
|
||||||
|
|
||||||
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0",
|
new PublishIISCommand(folders.PublishOutput, "netcoreapp1.0", null,
|
||||||
Path.Combine(folders.ProjectPath, "project.json")).Run();
|
Path.Combine(folders.ProjectPath, "project.json")).Run();
|
||||||
|
|
||||||
var aspNetCoreElement = GetPublishedWebConfig(folders.PublishOutput)
|
var aspNetCoreElement = GetPublishedWebConfig(folders.PublishOutput)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue