Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion documentation/general/dotnet-run-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ The directives are processed as follows:
- Each `#:include` is injected as `<{1} Include="{0}" />` in an `<ItemGroup>`
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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -706,6 +706,7 @@ public sealed class IncludeOrExclude(in ParseInfo info) : Named(info)
(".resx", "EmbeddedResource"),
(".json", "None"),
(".razor", "Content"),
(".dll", "Reference"),
];
}

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
""");
Expand Down Expand Up @@ -1851,7 +1850,6 @@ public static class LibClass
<PublishAot>true</PublishAot>
<PackAsTool>true</PackAsTool>
<UserSecretsId>Program-*</UserSecretsId>
<FileBasedProgramsItemMapping>.dll=Reference</FileBasedProgramsItemMapping>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -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());
""");
Expand Down Expand Up @@ -1976,6 +1973,9 @@ public static class LibClass

File.WriteAllText(Path.Join(srcDir, "Directory.Build.props"), $"""
<Project>
<PropertyGroup>
<{CSharpDirective.IncludeOrExclude.MappingPropertyName}></{CSharpDirective.IncludeOrExclude.MappingPropertyName}>
</PropertyGroup>
<ItemGroup>
<Reference Include="$(MSBuildThisFileDirectory){libDllPropsPath}" />
</ItemGroup>
Expand Down Expand Up @@ -2050,9 +2050,6 @@ public static class LibClass

File.WriteAllText(Path.Join(srcDir, "Directory.Build.props"), $"""
<Project>
<PropertyGroup>
<FileBasedProgramsItemMapping>.dll=Reference</FileBasedProgramsItemMapping>
</PropertyGroup>
<ItemGroup>
<Reference Include="$(MSBuildThisFileDirectory){libDllPropsPath}" />
</ItemGroup>
Expand Down Expand Up @@ -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}}
""");

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ public void Api()
<PackageOutputPath>artifacts/$(AssemblyName)</PackageOutputPath>
<FileBasedProgram>true</FileBasedProgram>
<EntryPointFilePath>{programPath}</EntryPointFilePath>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content</FileBasedProgramsItemMapping>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference</FileBasedProgramsItemMapping>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
<OutputType>Exe</OutputType>
Expand Down Expand Up @@ -1447,7 +1447,7 @@ public void Api_Evaluation()
<PackageOutputPath>artifacts/$(AssemblyName)</PackageOutputPath>
<FileBasedProgram>true</FileBasedProgram>
<EntryPointFilePath>{programPath}</EntryPointFilePath>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content</FileBasedProgramsItemMapping>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference</FileBasedProgramsItemMapping>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
Expand Down Expand Up @@ -1523,7 +1523,7 @@ public void Api_Diagnostic_01()
<PackageOutputPath>artifacts/$(AssemblyName)</PackageOutputPath>
<FileBasedProgram>true</FileBasedProgram>
<EntryPointFilePath>{programPath}</EntryPointFilePath>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content</FileBasedProgramsItemMapping>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference</FileBasedProgramsItemMapping>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
Expand Down Expand Up @@ -1598,7 +1598,7 @@ public void Api_Diagnostic_02()
<PackageOutputPath>artifacts/$(AssemblyName)</PackageOutputPath>
<FileBasedProgram>true</FileBasedProgram>
<EntryPointFilePath>{programPath}</EntryPointFilePath>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content</FileBasedProgramsItemMapping>
<FileBasedProgramsItemMapping>.cs=Compile;.resx=EmbeddedResource;.json=None;.razor=Content;.dll=Reference</FileBasedProgramsItemMapping>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DisableDefaultItemsInProjectFolder>true</DisableDefaultItemsInProjectFolder>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
Expand Down
Loading