diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs
index 7b68b6aa22af..4eb329760ec4 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs
@@ -51,7 +51,7 @@ protected override void ExecuteCore()
foreach (var item in FilesToBundle)
{
fileSpec.Add(new FileSpec(sourcePath: item.ItemSpec,
- bundleRelativePath:item.GetMetadata(MetadataKeys.RelativePath)));
+ bundleRelativePath: NormalizePathDirectorySeparator(item.GetMetadata(MetadataKeys.RelativePath))));
}
bundler.GenerateBundle(fileSpec);
@@ -64,5 +64,10 @@ protected override void ExecuteCore()
ExcludedFiles = FilesToBundle.Zip(fileSpec, (item, spec) => (spec.Excluded) ? item : null).Where(x => x != null).ToArray();
}
+
+ private static string NormalizePathDirectorySeparator(string path)
+ {
+ return path.Replace('\\', '/');
+ }
}
}
diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
index 66f66638f869..bbfd510af4f0 100644
--- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
+++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets
@@ -549,7 +549,7 @@ Copyright (c) .NET Foundation. All rights reserved.
- %(IntermediateSatelliteAssembliesWithTargetPath.Culture)\%(Filename)%(Extension)
+ %(IntermediateSatelliteAssembliesWithTargetPath.Culture)/%(Filename)%(Extension)
PreserveNewest
diff --git a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs
index 0f63a885876f..b1faf8c9028d 100644
--- a/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs
+++ b/src/Tests/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs
@@ -461,5 +461,113 @@ public void It_runs_single_file_apps(string targetFramework, bool selfContained,
.And
.HaveStdOutContaining("Hello World");
}
+
+ [RequiresMSBuildVersionTheory("16.8.0")]
+ [InlineData("netcoreapp3.0")]
+ [InlineData("netcoreapp3.1")]
+ [InlineData("net5.0")]
+ public void It_runs_single_file_apps_with_satellite_assemblies(string targetFramework)
+ {
+ var testProject = new TestProject()
+ {
+ Name = "SingleFileTest",
+ TargetFrameworks = targetFramework,
+ IsSdkProject = true,
+ IsExe = true,
+ SourceFiles =
+ {
+ ["Program.cs"] = @"
+ using System;
+
+ public static class Program
+ {
+ public static void Main()
+ {
+ Console.WriteLine(Strings.GetHelloWorld());
+ }
+ }",
+ ["Strings.cs"] = @"using System;
+ using System.Globalization;
+ using System.Reflection;
+ using System.Resources;
+ using System.Threading;
+
+ public class Strings
+ {
+ public static string GetHelloWorld()
+ {
+ CultureInfo.CurrentUICulture = new CultureInfo(""en-US"");
+ var resources = new ResourceManager(""Strings"", typeof(Strings).GetTypeInfo().Assembly);
+ return resources.GetString(""HelloWorld"");
+ }
+ }"
+ },
+ EmbeddedResources =
+ {
+ ["Strings.en-US.resx"] = @"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Hello World!
+
+ "
+ }
+ };
+
+ var testAsset = _testAssetsManager.CreateTestProject(testProject);
+ var publishCommand = new PublishCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name));
+
+ publishCommand.Execute(PublishSingleFile, RuntimeIdentifier)
+ .Should()
+ .Pass();
+
+ var publishDir = GetPublishDirectory(publishCommand, targetFramework).FullName;
+ var singleFilePath = Path.Combine(publishDir, $"{testProject.Name}{Constants.ExeSuffix}");
+
+ var command = new RunExeCommand(Log, singleFilePath);
+ command.Execute()
+ .Should()
+ .Pass()
+ .And
+ .HaveStdOutContaining("Hello World!");
+ }
}
}