diff --git a/scripts/dotnet-cli-build/TestTargets.cs b/scripts/dotnet-cli-build/TestTargets.cs index 78e24baaa..6a4bb2705 100644 --- a/scripts/dotnet-cli-build/TestTargets.cs +++ b/scripts/dotnet-cli-build/TestTargets.cs @@ -27,6 +27,7 @@ namespace Microsoft.DotNet.Cli.Build "dotnet-compile.UnitTests", "dotnet-build.Tests", "dotnet-pack.Tests", + "dotnet-resgen.Tests", "Microsoft.DotNet.Cli.Utils.Tests", "Microsoft.DotNet.Compiler.Common.Tests", "Microsoft.Extensions.DependencyModel.Tests", diff --git a/test/dotnet-resgen.Tests/Microsoft.DotNet.Tools.Resgen.Tests.cs b/test/dotnet-resgen.Tests/Microsoft.DotNet.Tools.Resgen.Tests.cs new file mode 100644 index 000000000..2568a4f42 --- /dev/null +++ b/test/dotnet-resgen.Tests/Microsoft.DotNet.Tools.Resgen.Tests.cs @@ -0,0 +1,52 @@ +// 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.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; +using Microsoft.DotNet.Tools.Test.Utilities; +using Microsoft.Extensions.PlatformAbstractions; +using Xunit; +using System; + +namespace Microsoft.DotNet.Tools.Resgen.Tests +{ + public class ResgenTests : TestBase + { + private readonly string _testProjectsRoot; + private readonly TempDirectory _root; + + public ResgenTests() + { + _testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects"); + _root = Temp.CreateDirectory(); + } + + [Fact] + public void Test_Build_Project_with_Resources_with_Space_in_Path() + { + var spaceBufferDirectory = _root.CreateDirectory("space directory"); + var testAppDir = spaceBufferDirectory.CreateDirectory("TestProjectWithResource"); + + CopyProjectToTempDir(Path.Combine(_testProjectsRoot, "TestProjectWithResource"), testAppDir); + + var testProject = GetProjectPath(testAppDir); + var buildCommand = new BuildCommand(testProject); + + var result = buildCommand.Execute().Should().Pass(); + } + + private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir) + { + foreach (var file in Directory.EnumerateFiles(projectDir)) + { + tempDir.CopyFile(file); + } + } + + private string GetProjectPath(TempDirectory projectDir) + { + return Path.Combine(projectDir.Path, "project.json"); + } + } +} diff --git a/test/dotnet-resgen.Tests/dotnet-resgen.Tests.xproj b/test/dotnet-resgen.Tests/dotnet-resgen.Tests.xproj new file mode 100644 index 000000000..7fdb3e11f --- /dev/null +++ b/test/dotnet-resgen.Tests/dotnet-resgen.Tests.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 386d412c-003c-47b1-8258-0e35865cb7c4 + Microsoft.DotNet.Tools.Resgen.Tests + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + + + + \ No newline at end of file diff --git a/test/dotnet-resgen.Tests/project.json b/test/dotnet-resgen.Tests/project.json new file mode 100644 index 000000000..47d7afe52 --- /dev/null +++ b/test/dotnet-resgen.Tests/project.json @@ -0,0 +1,28 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "NETStandard.Library": "1.0.0-rc2-23811", + + "Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" }, + "Microsoft.DotNet.Cli.Utils": { + "target": "project" + }, + + "xunit": "2.1.0", + "xunit.netcore.extensions": "1.0.0-prerelease-*", + "dotnet-test-xunit": "1.0.0-dev-48273-16" + }, + + "frameworks": { + "dnxcore50": { + "imports": "portable-net45+win8" + } + }, + + "content": [ + "../../TestAssets/TestProjects/TestProjectWithResource/**/*" + ], + + "testRunner": "xunit" +}