Skip to content

Conversation

@meaghanlewis
Copy link
Contributor

@meaghanlewis meaghanlewis commented Dec 17, 2025

Summary

Address comments from review feedback in: #50371

This pull request updates the documentation for file-based .NET apps, focusing on clarifying CLI usage, improving explanations of build and caching behavior, and providing more precise instructions for advanced scenarios. The changes aim to make the documentation more accurate and user-friendly by refining command syntax, clarifying default behaviors, and adding details on cache management and publishing.

CLI Command Usage and Syntax Improvements:

  • Clarified how to run file-based apps with dotnet run, emphasizing the use of the --file option and providing updated examples for passing arguments, including the recommended use of -- to separate app arguments.
  • Updated instructions for cleaning build artifacts, including new options like --days for cache cleanup and clarified the difference between deleting artifacts for a single file and a directory.
  • Improved explanations and examples for publishing (noting default native AOT publishing and how to disable it), packaging as a tool, and converting to a project, including details on default locations and how to override default behaviors.

NuGet and SDK Reference Syntax:

  • Updated NuGet package reference syntax from #:package Serilog version="3.1.1" to #:package [email protected] for consistency, and added an example for referencing a specific SDK version.

User Secrets and Advanced Features:

  • Updated user secrets commands to use the --file option instead of --project, and added an example for listing secrets.
  • Added a note about shebang requirements, specifying line endings and BOM constraints.

Build Output and Caching Behavior:

  • Clarified that the SDK generates a "virtual project" (not just a temporary one), and specified the default build output path with instructions for customizing it.
  • Expanded and clarified the section on build caching, emphasizing that the caching system is unique to file-based apps, and detailed what factors affect cache keys. Added explicit instructions for clearing cache artifacts.

Internal previews

📄 File 🔗 Preview link
docs/core/sdk/file-based-apps.md File-based apps

@meaghanlewis meaghanlewis changed the title Update file-based apps referencarticle based on review feedback Update file-based apps reference article Dec 17, 2025
```

The SDK generates a temporary project and builds your application.
The SDK generates a virtual project and builds your application. The default path for the build output is `./bin/<configuration>/<framework>/`. Use the `--output` option to specify a different path.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default output path is in the user profile directory and generally isn't visible to the user by default (it's in the directory cleared by the dotnet clean file-based-apps command, e.g. for Windows C:\Users\<username>\AppData\Local\Temp\dotnet\runfile\<appname>-<appfilesha>\bin\debug\). Easiest way to see it is by using the -getProperty option, e.g.:

> dotnet build hello.cs -getProperty=OutputPath
C:\Users\username\AppData\Local\Temp\dotnet\runfile\hello-1b946725adaab7fbf948510079efbd804fd48dbeeb8f1fa765bb7197dd8d5e73\bin\debug\

Using --output will change the output path for that build invocation, or the user can set the OutputPath property in their app using the directive:

#:property OutputPath=./output

```

File-based apps enable native AOT publishing by default, producing optimized, self-contained executables.
The default location of the executable is an `artifacts` directory next to the `.cs` file, with a subdirectory named after the application.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be changed by using --output again.

```

This command creates a `.csproj` file with equivalent SDK and properties. All `#` directives are removed from the `.cs` file and turned into elements in the corresponding `.csproj` file.
This command creates a `.csproj` file with equivalent SDK and properties. The command removes all `#:` directives from the `.cs` file and turns them into elements in the corresponding `.csproj` file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to make it clear the original .cs file is left untouched, and that the created project file is placed in a directory next to the original .cs file, along with a copy of the original .cs file with the #: directives removed.

## Build caching

The .NET SDK caches build outputs to improve performance on subsequent builds. File-based apps participate in this caching system.
The .NET SDK caches build outputs to improve performance on subsequent builds. This caching system is unique to file-based apps.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The .NET SDK caches build outputs to improve performance on subsequent builds. This caching system is unique to file-based apps.
The .NET SDK caches build outputs to improve performance on subsequent invocations of `dotnet run`. This caching system is unique to file-based apps.

- Directive configuration.
- SDK version.
- Implicit build files.
- SDK version. Implicit build files existence and content.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- SDK version. Implicit build files existence and content.
- SDK version.
- Implicit build files existence and content.

Copy link
Member

@DamianEdwards DamianEdwards left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Left a few comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants