rkttu
January 4, 2026, 4:18pm
1
정말 아쉽게도, .NET 10의 File-based App에서는 아직 여러 파일을 자연스럽게 포함시킬 방법이 마땅치 않습니다. 암묵적으로 Directory.Build.props 파일의 존재 여부를 기반으로 프로젝트 파일처럼 사용하는 것 정도가 최선으로 여겨지는데, 여기서 더 나아가서 MSBuild 속성을 약간 패치하는 방식으로 구현한 사례가 흥미로워 공유해봅니다.
#:property Imports=TestHelper.cs
using static Test.TestHelper;
PrintMessage(
"Hello from multi-file test!"
);
위와 같은 코드를 구현하기 위하여 Directory.Build.targets 파일을 아래와 같이 구성할 수 있습니다.
<Project>
<ItemGroup Condition="'$(Imports)' != ''">
<_ImportedFiles Include="$(Imports.Split(';'))" />
<Compile Include="@(_ImportedFiles)" />
</ItemGroup>
</Project>
그리고 TestHelper.cs의 내용은 다음과 같습니다.
namespace Test;
public static class TestHelper
{
public static void PrintMessage
(string message)
{
Console.WriteLine(message);
}
}
추후 .NET 11에 와서 더 개선될 여지가 있겠으나, 이것도 흥미로운 접근법이고 하나의 방편일 것 같습니다.
7 Likes
셔뱅으로는 ItemGroup이나 msbuild의 모든 부분을 다룰수는 없다보니 계속 아쉽기는 해요. 뭐 당장 닷넷에서의 입장은 그런게 필요할 정도면 FBA에서 .csproj로 전환하라고 하지만..ㅋㅋㅠ
3 Likes
rkttu
April 16, 2026, 8:01am
3
.NET 11 Preview 3에서는 드디어 #:include 지시자가 들어가게되었습니다.
# .NET SDK in .NET 11 Preview 3 - Release Notes
.NET 11 Preview 3 includes new SDK and CLI improvements:
- [Solution filters can now be edited from the CLI](#solution-filters-can-now-be-edited-from-the-cli)
- [File-based apps can be split across files](#file-based-apps-can-be-split-across-files)
- [`dotnet run -e` passes environment variables from the command line](#dotnet-run--e-passes-environment-variables-from-the-command-line)
- [`dotnet watch` adds Aspire, crash recovery, and Windows desktop improvements](#dotnet-watch-adds-aspire-crash-recovery-and-windows-desktop-improvements)
- [Other CLI improvements](#other-cli-improvements)
- [Bug fixes](#bug-fixes)
- [Community contributors](#community-contributors)
.NET SDK updates in .NET 11:
- [What's new in .NET 11](https://learn.microsoft.com/dotnet/core/whats-new/dotnet-11/sdk)
## Solution filters can now be edited from the CLI
`dotnet sln` can now create and edit solution filters (`.slnf`) directly from
the CLI ([dotnet/sdk #51156](https://github.com/dotnet/sdk/pull/51156)). This
This file has been truncated. show original
4 Likes