RefFile 0.2.0
dotnet add package RefFile --version 0.2.0
NuGet\Install-Package RefFile -Version 0.2.0
<PackageReference Include="RefFile" Version="0.2.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
<PackageVersion Include="RefFile" Version="0.2.0" />
<PackageReference Include="RefFile"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
paket add RefFile --version 0.2.0
#r "nuget: RefFile, 0.2.0"
#:package RefFile@0.2.0
#addin nuget:?package=RefFile&version=0.2.0
#tool nuget:?package=RefFile&version=0.2.0
RefFile
A generator for .NET 10 file-based apps, designed to reference external source files.
This generator allows you to reference another file and include its contents in the build.
Since multi-file support for file-based apps is expected to be added in .NET 11, this is intended as a temporary workaround until then.
Note that this generator assumes the referenced file is C# source code.
It is not valid for other types of files.
Usage
Add the RefFileAttribute to the assembly and specify the referenced filename as its argument.
The filename is interpreted as a relative path from the file where the attribute is declared.
Important note: any file-based apps directives written at the beginning of the referenced file will be removed.
Therefore, directives such as #:package or #:property inside the referenced file will have no effect.
Example
common.cs
#:package Humanizer.Core@3.0.1 // File-based directives within referenced files will be deleted. using Humanizer; public record CommonData(long Value) { public void Print() => Console.WriteLine(this.Value.ToMetric(decimals: 2)); }app.cs
#!/usr/bin/env -S dotnet run --file #:package RefFile@0.2.0 // Package references should be written in the main file. #:package Humanizer.Core@3.0.1 [assembly: RefFile("common.cs")] var data = new CommonData(123456); data.Print();
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.2.0 | 702 | 12/1/2025 |