diff --git a/TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs b/TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs new file mode 100644 index 000000000..dcdd3eaa1 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithUnicodéPath/Program.cs @@ -0,0 +1,12 @@ +using System; + +namespace ConsoleApplication +{ + public class Program + { + public static void Main(string[] args) + { + Console.WriteLine("Hélló Wórld!"); + } + } +} diff --git a/TestAssets/TestProjects/TestAppWithUnicodéPath/project.json b/TestAssets/TestProjects/TestAppWithUnicodéPath/project.json new file mode 100644 index 000000000..0c076f5f1 --- /dev/null +++ b/TestAssets/TestProjects/TestAppWithUnicodéPath/project.json @@ -0,0 +1,22 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "emitEntryPoint": true + }, + "dependencies": { + "Microsoft.NETCore.App": "1.0.0-rc2-*" + }, + "frameworks": { + "netcoreapp1.0": { } + }, + "runtimes": { + "win7-x64": {}, + "win7-x86": {}, + "osx.10.10-x64": {}, + "osx.10.11-x64": {}, + "ubuntu.14.04-x64": {}, + "centos.7-x64": {}, + "rhel.7.2-x64": {}, + "debian.8-x64": {} + } +} diff --git a/src/dotnet/Program.cs b/src/dotnet/Program.cs index 2ecbed88b..1ab628b14 100644 --- a/src/dotnet/Program.cs +++ b/src/dotnet/Program.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; using Microsoft.DotNet.Cli.Utils; using Microsoft.DotNet.ProjectModel.Server; using Microsoft.DotNet.Tools.Build; @@ -41,6 +42,8 @@ namespace Microsoft.DotNet.Cli { DebugHelper.HandleDebugSwitch(ref args); + InitializeProcess(); + try { return Program.ProcessArgs(args, new Telemetry()); @@ -138,6 +141,13 @@ namespace Microsoft.DotNet.Cli } + private static void InitializeProcess() + { + // by default, .NET Core doesn't have all code pages needed for Console apps. + // see the .NET Core Notes in https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + } + internal static bool TryGetBuiltInCommand(string commandName, out Func builtInCommand) { return s_builtIns.TryGetValue(commandName, out builtInCommand); diff --git a/test/ArgumentForwardingTests/ArgumentForwardingTests.cs b/test/ArgumentForwardingTests/ArgumentForwardingTests.cs index 95be0edaa..ed08e45bf 100644 --- a/test/ArgumentForwardingTests/ArgumentForwardingTests.cs +++ b/test/ArgumentForwardingTests/ArgumentForwardingTests.cs @@ -51,6 +51,7 @@ namespace Microsoft.DotNet.Tests.ArgumentForwarding /// [Theory] [InlineData(@"""abc"" d e")] + [InlineData(@"""ábc"" d é")] [InlineData(@"""abc"" d e")] [InlineData("\"abc\"\t\td\te")] [InlineData(@"a\\b d""e f""g h")] diff --git a/test/dotnet-build.Tests/GivenDotnetBuildBuildsProjects.cs b/test/dotnet-build.Tests/GivenDotnetBuildBuildsProjects.cs new file mode 100644 index 000000000..d05471455 --- /dev/null +++ b/test/dotnet-build.Tests/GivenDotnetBuildBuildsProjects.cs @@ -0,0 +1,46 @@ +// 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.IO; +using FluentAssertions; +using Microsoft.DotNet.Tools.Test.Utilities; +using Xunit; + +namespace Microsoft.DotNet.Tools.Builder.Tests +{ + public class GivenDotnetBuildBuildsProjects : TestBase + { + [Fact] + public void It_builds_projects_with_Unicode_in_path() + { + var testInstance = TestAssetsManager + .CreateTestInstance("TestAppWithUnicodéPath") + .WithLockFiles(); + + var testProjectDirectory = testInstance.TestRoot; + + var buildCommand = new BuildCommand(""); + buildCommand.WorkingDirectory = testProjectDirectory; + + buildCommand.ExecuteWithCapturedOutput() + .Should() + .Pass(); + } + + [Fact] + public void It_builds_projects_with_Unicode_in_path_project_path_passed() + { + var testInstance = TestAssetsManager + .CreateTestInstance("TestAppWithUnicodéPath") + .WithLockFiles(); + + var testProject = Path.Combine(testInstance.TestRoot, "project.json"); + + new BuildCommand(testProject) + .ExecuteWithCapturedOutput() + .Should() + .Pass(); + } + } +} diff --git a/test/dotnet-run.Tests/RunTests.cs b/test/dotnet-run.Tests/RunTests.cs index b41ecce8b..41de0dd2e 100644 --- a/test/dotnet-run.Tests/RunTests.cs +++ b/test/dotnet-run.Tests/RunTests.cs @@ -68,6 +68,19 @@ namespace Microsoft.DotNet.Tools.Run.Tests new RunCommand(instance.TestRoot).Execute().Should().Pass(); } + [Fact] + public void ItRunsAppsThatOutputUnicodeCharacters() + { + TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithUnicodéPath") + .WithLockFiles() + .WithBuildArtifacts(); + new RunCommand(instance.TestRoot) + .ExecuteWithCapturedOutput() + .Should() + .Pass() + .And + .HaveStdOutContaining("Hélló Wórld!"); + } private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir) {