diff --git a/cli.slnf b/cli.slnf index e487d67ba499..a3ecb6ff2ed3 100644 --- a/cli.slnf +++ b/cli.slnf @@ -7,6 +7,7 @@ "src\\Cli\\dn\\dn-native-debug.vcxproj", "src\\Cli\\dotnet\\dotnet.csproj", "src\\Cli\\Microsoft.DotNet.Cli.Utils\\Microsoft.DotNet.Cli.Utils.csproj", + "src\\Microsoft.DotNet.ProjectTools\\Microsoft.DotNet.ProjectTools.csproj", "test\\dotnet-new.IntegrationTests\\dotnet-new.IntegrationTests.csproj", "test\\dotnet-watch.Tests\\dotnet-watch.Tests.csproj", "test\\dotnet-aot.Tests\\dotnet-aot.Tests.csproj", diff --git a/documentation/general/dotnet-run-file.md b/documentation/general/dotnet-run-file.md index 1a09f48040ce..ce49aa4bce06 100644 --- a/documentation/general/dotnet-run-file.md +++ b/documentation/general/dotnet-run-file.md @@ -235,7 +235,7 @@ The directives are processed as follows: - Each `#:include` is injected as `<{1} Include="{0}" />` in an `` where `{0}` is the directive's value and `{1}` is determined by its extension. The mapping can be customized by setting the MSBuild property `FileBasedProgramsItemMapping` - which is by default set to `.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content`. + which is by default set to `.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference`. It is an error if the value is empty. diff --git a/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs b/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs index c038e131e753..9d4e7fb64f93 100644 --- a/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs +++ b/src/Cli/Microsoft.DotNet.FileBasedPrograms/FileLevelDirectiveHelpers.cs @@ -692,7 +692,7 @@ public sealed class IncludeOrExclude(in ParseInfo info) : Named(info) { public const string MappingPropertyName = "FileBasedProgramsItemMapping"; - public static string DefaultMappingString => ".cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content"; + public static string DefaultMappingString => ".cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference"; public static ImmutableArray<(string Extension, string ItemType)> DefaultMapping { @@ -706,6 +706,7 @@ public sealed class IncludeOrExclude(in ParseInfo info) : Named(info) (".resx", "EmbeddedResource"), (".json", "None"), (".razor", "Content"), + (".dll", "Reference"), ]; } @@ -833,7 +834,7 @@ public string KindToMSBuildString() SourceFile sourceFile, ErrorReporter errorReporter) { - var pairs = value.Split(';'); + var pairs = value.Split([';'], StringSplitOptions.RemoveEmptyEntries); var builder = ImmutableArray.CreateBuilder<(string Extension, string ItemType)>(pairs.Length); diff --git a/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs b/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs index 59a31b2d8d38..f51472c02f8e 100644 --- a/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs +++ b/test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs @@ -1821,7 +1821,6 @@ public static class LibClass var libDllProjectPath = Path.Join("Lib", "bin", "Debug", ToolsetInfo.CurrentTargetFramework, "Lib.dll"); File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), $$""" - #:property FileBasedProgramsItemMapping=.dll=Reference #:include {{libDllDirectivePath}} Console.WriteLine(Lib.LibClass.GetMessage()); """); @@ -1851,7 +1850,6 @@ public static class LibClass true true Program-* - .dll=Reference @@ -1908,7 +1906,6 @@ public static class LibClass Path.Join(testInstance.Path, "Lib.dll")); File.WriteAllText(Path.Join(testInstance.Path, "Program.cs"), """ - #:property FileBasedProgramsItemMapping=.dll=Reference #:include *.dll Console.WriteLine(Lib.LibClass.GetMessage()); """); @@ -1976,6 +1973,9 @@ public static class LibClass File.WriteAllText(Path.Join(srcDir, "Directory.Build.props"), $""" + + <{CSharpDirective.IncludeOrExclude.MappingPropertyName}> + @@ -2050,9 +2050,6 @@ public static class LibClass File.WriteAllText(Path.Join(srcDir, "Directory.Build.props"), $""" - - .dll=Reference - @@ -2121,7 +2118,6 @@ public static class LibClass var libDllProjectPath = Path.Join("Lib", "bin", "Debug", ToolsetInfo.CurrentTargetFramework, "Lib.dll"); File.WriteAllText(Path.Join(testInstance.Path, "extra.cs"), $$""" - #:property FileBasedProgramsItemMapping=.dll=Reference #:include {{libDllDirectivePath}} """); @@ -2201,7 +2197,6 @@ public static class DependencyClass File.WriteAllText(Path.Join(libDir, "lib.cs"), $$""" #:property OutputType=Library - #:property FileBasedProgramsItemMapping=.dll=Reference #:include {{dependencyDllDirectivePath}} namespace MyLib; public static class Wrapper diff --git a/test/dotnet.Tests/CommandTests/Run/RunFileTests_CscOnlyAndApi.cs b/test/dotnet.Tests/CommandTests/Run/RunFileTests_CscOnlyAndApi.cs index 17455ae98aeb..6a6e377c79cd 100644 --- a/test/dotnet.Tests/CommandTests/Run/RunFileTests_CscOnlyAndApi.cs +++ b/test/dotnet.Tests/CommandTests/Run/RunFileTests_CscOnlyAndApi.cs @@ -1362,7 +1362,7 @@ public void Api() artifacts/$(AssemblyName) true {programPath} - .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content + .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference false true Exe @@ -1447,7 +1447,7 @@ public void Api_Evaluation() artifacts/$(AssemblyName) true {programPath} - .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content + .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference false true false @@ -1523,7 +1523,7 @@ public void Api_Diagnostic_01() artifacts/$(AssemblyName) true {programPath} - .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content + .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference false true false @@ -1598,7 +1598,7 @@ public void Api_Diagnostic_02() artifacts/$(AssemblyName) true {programPath} - .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content + .cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference false true false