-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Area-run-fileItems related to the "dotnet run <file>" effortItems related to the "dotnet run <file>" effort
Milestone
Description
The default output directory for publishing file-based apps, ./artifacts/<app name>, next to the app file, is not excluded from the app's default non-compile items. This is especially problematic for app's using the Microsoft.NET.Sdk.Web SDK which includes *.json files in its default items. This results in issues if you call publish multiple times without clearing the output directory, as the JSON files in the output directory get included in the next publish command.
Repro steps:
- Create a file-based app, e.g.
app.csusing the web SDK:#:sdk Microsoft.NET.Sdk.Web #:property PublishAot=false var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.MapGet("/", () => "Hello World!"); app.Run();
- Run
dotnet publish app.cs - There will now be an
artifacts/appdirectory next to theapp.csfile, containing the publish output - Run
dotnet publish app.csagain
a. This can also be a container publish:
dotnet publish app.cs --os linux --arch x64 -t:PublishContainer - Observe the warnings about files being in use. If the publish succeeds (I've seen it fail, I've seen retries on the file in use succeed), note the publish output directory now contains "recursive" items, e.g.
./artifacts/app/artifacts/app/*.json
We might want to consider updating the default non-compile items globs for file-based apps to exclude the artifacts directory.
Copilot
Metadata
Metadata
Labels
Area-run-fileItems related to the "dotnet run <file>" effortItems related to the "dotnet run <file>" effort