diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets index a6780901d68a..42bfb278d1a1 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets @@ -95,6 +95,13 @@ Copyright (c) .NET Foundation. All rights reserved. ('$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(_TargetFrameworkVersionWithoutV)' >= '3.0')">true + + true + + _CheckForBuildWithNoBuild; diff --git a/src/Tests/Microsoft.NET.Build.Tests/GenerateResourceTests.cs b/src/Tests/Microsoft.NET.Build.Tests/GenerateResourceTests.cs new file mode 100644 index 000000000000..ce35e96b96c7 --- /dev/null +++ b/src/Tests/Microsoft.NET.Build.Tests/GenerateResourceTests.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Microsoft.NET.TestFramework; +using Microsoft.NET.TestFramework.Assertions; +using Microsoft.NET.TestFramework.Commands; +using Microsoft.NET.TestFramework.ProjectConstruction; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.NET.Build.Tests +{ + public class GenerateResourceTests : SdkTest + { + + public GenerateResourceTests(ITestOutputHelper log) : base(log) + { + } + + [Theory(Skip="https://github.com/microsoft/msbuild/issues/4488")] + [InlineData("netcoreapp3.0", true)] + public void DependentUponTest(string targetFramework, bool isExe) + { + var testProject = new TestProject + { + Name = "HelloWorld", + IsSdkProject = true, + TargetFrameworks = targetFramework, + IsExe = isExe, + SourceFiles = + { + ["Program.cs"] = @" + using System; + + namespace SomeNamespace + { + public static class SomeClass + { + public static void Main(string[] args) + { + var resourceManager = new global::System.Resources.ResourceManager(""SomeNamespace.SomeClass"", typeof(SomeClass).Assembly); + Console.WriteLine(resourceManager.GetString(""SomeString"")); + } + } + } + ", + }, + EmbeddedResources = + { + ["Program.resx"] = @" + + + Hello world from a resource! + + + ", + } + }; + + var testAsset = _testAssetsManager + .CreateTestProject(testProject, identifier: targetFramework + isExe) + .Restore(Log, testProject.Name); + + var buildCommand = new BuildCommand( + Log, + Path.Combine(testAsset.TestRoot, testProject.Name)); + + buildCommand + .Execute() + .Should() + .Pass(); + + var outputDirectory = buildCommand.GetOutputDirectory(targetFramework); + + var runCommand = new RunExeCommand(Log, Path.Combine(outputDirectory.FullName, "HelloWorld.exe")); + runCommand + .Execute() + .Should() + .Pass() + .And.HaveStdOutContaining("Hello world from a resource!"); + } + } +}