Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f33c9db
Update dependencies from https://github.com/dotnet/arcade build 20200…
dotnet-maestro[bot] Jul 16, 2020
df71ee0
Enable builds of internal branches (#12517)
mmitche Jul 16, 2020
3cb3695
[release/5.0.1xx-preview8] Update dependencies from microsoft/msbuild…
dotnet-maestro[bot] Jul 17, 2020
e36cc98
Update dependencies from https://github.com/dotnet/fsharp build 20200…
dotnet-maestro[bot] Jul 18, 2020
aac822b
Only include the LaunchSettings & ServiceDependencies in None if present
vijayrkn Jul 17, 2020
2a3755a
Merge pull request #12533 from dotnet/vramak/FixSDGlobIssue
vijayrkn Jul 20, 2020
37c8a74
Update dependencies from https://github.com/dotnet/roslyn build 20200…
dotnet-maestro[bot] Jul 21, 2020
dab2534
Update dependencies from https://github.com/dotnet/fsharp build 20200…
dotnet-maestro[bot] Jul 21, 2020
b4ac34c
[release/5.0.1xx-preview8] Update dependencies from microsoft/msbuild…
dotnet-maestro[bot] Jul 21, 2020
3d3019a
Update dependencies from https://github.com/NuGet/NuGet.Client build …
dotnet-maestro[bot] Jul 21, 2020
083cb7f
Merge preview 7 to preview 8 (#12577)
sfoslund Jul 21, 2020
2827b99
Internal feeds for Preview 8 (#12556)
lukas-lansky Jul 21, 2020
fb9d532
[release/5.0.1xx-preview8] Update dependencies from dotnet/fsharp (#1…
dotnet-maestro[bot] Jul 22, 2020
a920d61
[release/5.0.1xx-preview8] Update dependencies from dotnet/roslyn (#1…
dotnet-maestro[bot] Jul 22, 2020
a6ecb3e
[release/5.0.1xx-preview8] Update dependencies from dotnet/fsharp (#1…
dotnet-maestro[bot] Jul 22, 2020
28d7993
Update dependencies from https://github.com/dotnet/fsharp build 20200…
dotnet-maestro[bot] Jul 23, 2020
d9ae880
Update dependencies from https://github.com/dotnet/roslyn build 20200…
dotnet-maestro[bot] Jul 23, 2020
285cac3
Show a message when building as part of dotnet-run (#12581)
pranavkm Jul 23, 2020
c7e7130
Parse target platform properties from target framework
sfoslund Jun 25, 2020
c245d35
Replacing old logic for parsing target framework properties
sfoslund Jun 26, 2020
1c295c7
PR feedback
sfoslund Jun 30, 2020
50b8fad
Error on unsupported target platform identifier
sfoslund Jul 1, 2020
113031d
Update VS version to 16.8
sfoslund Jul 20, 2020
cbedf95
Temporarily disabling full framework c++ tests
sfoslund Jul 20, 2020
41bcf94
Fix merge issues
sfoslund Jul 23, 2020
c0f65b1
Error on unsupported Windows TargetPlatformVersion
sfoslund Jul 17, 2020
108416d
PR feedback
sfoslund Jul 21, 2020
fcad556
Add WindowsOnlyRequiresMSBuildVersion fact and theory test attributes
sfoslund Jul 8, 2020
ac85508
Fix merge issues
sfoslund Jul 23, 2020
ce24326
PR feedback
sfoslund Jul 23, 2020
f19d2d2
Clean up from merge
sfoslund Jul 17, 2020
f283269
Clean up from merge
sfoslund Jul 17, 2020
fc32d1d
Merge pull request #12612 from sfoslund/ParseTPPrev8
sfoslund Jul 23, 2020
b204893
Only set Windows as target platform when UseWPF or UseWindowsForms
sfoslund Jul 23, 2020
a7e31f9
Merge remote-tracking branch 'upstream/release/5.0.1xx-preview8' into…
sfoslund Jul 23, 2020
66133d2
Update dependencies from https://github.com/dotnet/fsharp build 20200…
dotnet-maestro[bot] Jul 23, 2020
6ffaf21
Merge pull request #12613 from sfoslund/UnsupportedTPVPrev8
sfoslund Jul 24, 2020
52dc3f1
Update dependencies from https://github.com/dotnet/roslyn build 20200…
dotnet-maestro[bot] Jul 24, 2020
7309214
Merge remote-tracking branch 'upstream/release/5.0.1xx-preview8' into…
sfoslund Jul 24, 2020
f333263
Fixing merge issues
sfoslund Jul 24, 2020
dbbbc27
Revert Internal feeds for Preview 8 (#12556)
sfoslund Jul 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/restore-toolset.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function InitializeCustomSDKToolset {
if ($env:TestFullMSBuild -eq "true") {
$env:DOTNET_SDK_TEST_MSBUILD_PATH = InitializeVisualStudioMSBuild -install:$false -vsRequirements:$GlobalJson.tools.'vs-opt'
$env:DOTNET_SDK_TEST_MSBUILD_PATH = InitializeVisualStudioMSBuild -install:$true -vsRequirements:$GlobalJson.tools.'vs-opt'
Write-Host "INFO: Tests will run against full MSBuild in $env:DOTNET_SDK_TEST_MSBUILD_PATH"
}

Expand Down
5 changes: 3 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
]
},
"vs-opt": {
"version": "15.9"
}
"version": "16.8"
},
"xcopy-msbuild": "16.8.0-preview1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.20364.3",
Expand Down
16 changes: 16 additions & 0 deletions src/Assets/TestProjects/TestAppWithLaunchSettings/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello world");
Console.WriteLine($"MyCoolEnvironmentVariableKey={Environment.GetEnvironmentVariable("MyCoolEnvironmentVariableKey")}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"profiles": {
"TestAppWithLaunchSettings": {
"commandName": "Project",
"dotnetRunMessages": "true",
"environmentVariables": {
"MyCoolEnvironmentVariableKey": "MyCoolEnvironmentVariableValue"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ namespace Microsoft.DotNet.Tools.Run.LaunchSettings
{
internal interface ILaunchSettingsProvider
{
string CommandName { get; }

LaunchSettingsApplyResult TryApplySettings(JsonElement model, ref ICommand command);
LaunchSettingsApplyResult TryGetLaunchSettings(JsonElement model);
}

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DotNet.Tools.Run.LaunchSettings
{
public class LaunchSettingsApplyResult
{
public LaunchSettingsApplyResult(bool success, string failureReason, string runAfterLaunch = null)
public LaunchSettingsApplyResult(bool success, string failureReason, ProjectLaunchSettingsModel launchSettings = null)
{
Success = success;
FailureReason = failureReason;
RunAfterLaunch = runAfterLaunch;
LaunchSettings = launchSettings;
}

public bool Success { get; }

public string FailureReason { get; }

public string RunAfterLaunch { get; }
public ProjectLaunchSettingsModel LaunchSettings { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
Expand All @@ -21,7 +24,7 @@ static LaunchSettingsManager()
};
}

public static LaunchSettingsApplyResult TryApplyLaunchSettings(string launchSettingsJsonContents, ref ICommand command, string profileName = null)
public static LaunchSettingsApplyResult TryApplyLaunchSettings(string launchSettingsJsonContents, string profileName = null)
{
try
{
Expand Down Expand Up @@ -90,7 +93,7 @@ public static LaunchSettingsApplyResult TryApplyLaunchSettings(string launchSett
return new LaunchSettingsApplyResult(false, string.Format(LocalizableStrings.LaunchProfileHandlerCannotBeLocated, commandName));
}

return provider.TryApplySettings(profileObject, ref command);
return provider.TryGetLaunchSettings(profileObject);
}
}
catch (JsonException ex)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;

namespace Microsoft.DotNet.Tools.Run.LaunchSettings
{
public class ProjectLaunchSettingsModel
{
public string CommandLineArgs { get; set; }

public bool LaunchBrowser { get; set; }

public string LaunchUrl { get; set; }

public string ApplicationUrl { get; set; }

public string DotNetRunMessages { get; set; }

public Dictionary<string, string> EnvironmentVariables { get; } = new Dictionary<string, string>(StringComparer.Ordinal);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Text.Json;
using Microsoft.DotNet.Cli.Utils;

namespace Microsoft.DotNet.Tools.Run.LaunchSettings
{
Expand All @@ -11,7 +12,7 @@ internal class ProjectLaunchSettingsProvider : ILaunchSettingsProvider

public string CommandName => CommandNameValue;

public LaunchSettingsApplyResult TryApplySettings(JsonElement model, ref ICommand command)
public LaunchSettingsApplyResult TryGetLaunchSettings(JsonElement model)
{
var config = new ProjectLaunchSettingsModel();
foreach (var property in model.EnumerateObject())
Expand Down Expand Up @@ -52,14 +53,23 @@ public LaunchSettingsApplyResult TryApplySettings(JsonElement model, ref IComman

config.ApplicationUrl = applicationUrlValue;
}
else if (string.Equals(property.Name, nameof(ProjectLaunchSettingsModel.DotNetRunMessages), StringComparison.OrdinalIgnoreCase))
{
if (!TryGetStringValue(property.Value, out var dotNetRunMessages))
{
return new LaunchSettingsApplyResult(false, string.Format(LocalizableStrings.CouldNotConvertToString, property.Name));
}

config.DotNetRunMessages = dotNetRunMessages;
}
else if (string.Equals(property.Name, nameof(ProjectLaunchSettingsModel.EnvironmentVariables), StringComparison.OrdinalIgnoreCase))
{
if (property.Value.ValueKind != JsonValueKind.Object)
{
return new LaunchSettingsApplyResult(false, string.Format(LocalizableStrings.ValueMustBeAnObject, property.Name));
}

foreach(var environmentVariable in property.Value.EnumerateObject())
foreach (var environmentVariable in property.Value.EnumerateObject())
{
if (TryGetStringValue(environmentVariable.Value, out var environmentVariableValue))
{
Expand All @@ -69,21 +79,7 @@ public LaunchSettingsApplyResult TryApplySettings(JsonElement model, ref IComman
}
}

if (!string.IsNullOrEmpty(config.ApplicationUrl))
{
command.EnvironmentVariable("ASPNETCORE_URLS", config.ApplicationUrl);
}

//For now, ignore everything but the environment variables section

foreach (var entry in config.EnvironmentVariables)
{
string value = Environment.ExpandEnvironmentVariables(entry.Value);
//NOTE: MSBuild variables are not expanded like they are in VS
command.EnvironmentVariable(entry.Key, value);
}

return new LaunchSettingsApplyResult(true, null, config.LaunchUrl);
return new LaunchSettingsApplyResult(true, null, config);
}

private static bool TryGetBooleanValue(JsonElement element, out bool value)
Expand Down Expand Up @@ -136,23 +132,5 @@ private static bool TryGetStringValue(JsonElement element, out string value)
return false;
}
}

private class ProjectLaunchSettingsModel
{
public ProjectLaunchSettingsModel()
{
EnvironmentVariables = new Dictionary<string, string>(StringComparer.Ordinal);
}

public string CommandLineArgs { get; set; }

public bool LaunchBrowser { get; set; }

public string LaunchUrl { get; set; }

public string ApplicationUrl { get; set; }

public Dictionary<string, string> EnvironmentVariables { get; }
}
}
}
5 changes: 4 additions & 1 deletion src/Cli/dotnet/commands/dotnet-run/LocalizableStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<data name="RuntimeOptionDescription" xml:space="preserve">
<value>The target runtime to run for.</value>
</data>
<data name="RunCommandBuilding" xml:space="preserve">
<value>Building...</value>
</data>
<data name="RunCommandException" xml:space="preserve">
<value>The build failed. Fix the build errors and run again.</value>
</data>
Expand Down Expand Up @@ -214,4 +217,4 @@ The current {1} is '{2}'.</value>
<data name="ValueMustBeAnObject" xml:space="preserve">
<value>The property '{0}' must be an object if it is specified.</value>
</data>
</root>
</root>
40 changes: 32 additions & 8 deletions src/Cli/dotnet/commands/dotnet-run/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using Microsoft.Build.Execution;
using Microsoft.Build.Exceptions;
using Microsoft.DotNet.Cli.Utils;
using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Tools.MSBuild;
using Microsoft.DotNet.Tools.Run.LaunchSettings;
using Microsoft.DotNet.CommandFactory;

Expand Down Expand Up @@ -41,17 +39,37 @@ public int Execute()
{
Initialize();

if (!TryGetLaunchProfileSettingsIfNeeded(out var launchSettings))
{
return 1;
}

if (ShouldBuild)
{
if (string.Equals("true", launchSettings?.DotNetRunMessages, StringComparison.OrdinalIgnoreCase))
{
Reporter.Output.WriteLine(LocalizableStrings.RunCommandBuilding);
}

EnsureProjectIsBuilt();
}

try
{
ICommand targetCommand = GetTargetCommand();
if (!ApplyLaunchProfileSettingsIfNeeded(ref targetCommand))
if (launchSettings != null)
{
return 1;
if (!string.IsNullOrEmpty(launchSettings.ApplicationUrl))
{
targetCommand.EnvironmentVariable("ASPNETCORE_URLS", launchSettings.ApplicationUrl);
}

foreach (var entry in launchSettings.EnvironmentVariables)
{
string value = Environment.ExpandEnvironmentVariables(entry.Value);
//NOTE: MSBuild variables are not expanded like they are in VS
targetCommand.EnvironmentVariable(entry.Key, value);
}
}

// Ignore Ctrl-C for the remainder of the command's execution
Expand Down Expand Up @@ -92,8 +110,9 @@ public RunCommand(string configuration,
Interactive = interactive;
}

private bool ApplyLaunchProfileSettingsIfNeeded(ref ICommand targetCommand)
private bool TryGetLaunchProfileSettingsIfNeeded(out ProjectLaunchSettingsModel launchSettingsModel)
{
launchSettingsModel = default;
if (!UseLaunchProfile)
{
return true;
Expand All @@ -117,7 +136,8 @@ private bool ApplyLaunchProfileSettingsIfNeeded(ref ICommand targetCommand)

if (File.Exists(launchSettingsPath))
{
if (!HasQuietVerbosity) {
if (!HasQuietVerbosity)
{
Reporter.Output.WriteLine(string.Format(LocalizableStrings.UsingLaunchSettingsFromMessage, launchSettingsPath));
}

Expand All @@ -126,11 +146,15 @@ private bool ApplyLaunchProfileSettingsIfNeeded(ref ICommand targetCommand)
try
{
var launchSettingsFileContents = File.ReadAllText(launchSettingsPath);
var applyResult = LaunchSettingsManager.TryApplyLaunchSettings(launchSettingsFileContents, ref targetCommand, LaunchProfile);
var applyResult = LaunchSettingsManager.TryApplyLaunchSettings(launchSettingsFileContents, LaunchProfile);
if (!applyResult.Success)
{
Reporter.Error.WriteLine(string.Format(LocalizableStrings.RunCommandExceptionCouldNotApplyLaunchSettings, profileName, applyResult.FailureReason).Bold().Red());
}
else
{
launchSettingsModel = applyResult.LaunchSettings;
}
}
catch (IOException ex)
{
Expand All @@ -155,7 +179,7 @@ private void EnsureProjectIsBuilt()
new RestoringCommand(
restoreArgs.Prepend(Project),
restoreArgs,
new [] { Project },
new[] { Project },
NoRestore
).Execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<target state="translated">Hodnotu vlastnosti {0} nejde převést na řetězec.</target>
<note />
</trans-unit>
<trans-unit id="RunCommandBuilding">
<source>Building...</source>
<target state="new">Building...</target>
<note />
</trans-unit>
<trans-unit id="RunCommandException">
<source>The build failed. Fix the build errors and run again.</source>
<target state="translated">Sestavení se nepovedlo. Opravte v sestavení chyby a spusťte ho znovu.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<target state="translated">Der Wert der Eigenschaft "{0}" konnte nicht in eine Zeichenfolge konvertiert werden.</target>
<note />
</trans-unit>
<trans-unit id="RunCommandBuilding">
<source>Building...</source>
<target state="new">Building...</target>
<note />
</trans-unit>
<trans-unit id="RunCommandException">
<source>The build failed. Fix the build errors and run again.</source>
<target state="translated">Fehler beim Buildvorgang. Beheben Sie die Buildfehler, und versuchen Sie es anschließend noch mal.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
<target state="translated">No se pudo convertir el valor de la propiedad "{0}" en una cadena.</target>
<note />
</trans-unit>
<trans-unit id="RunCommandBuilding">
<source>Building...</source>
<target state="new">Building...</target>
<note />
</trans-unit>
<trans-unit id="RunCommandException">
<source>The build failed. Fix the build errors and run again.</source>
<target state="translated">No se pudo llevar a cabo la compilación. Corrija los errores de compilación y vuelva a ejecutar el proyecto.</target>
Expand Down
Loading