dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.38k stars 10k forks source link

dotnet publish --no-build with separate build #46156

Open pcappaert opened 1 year ago

pcappaert commented 1 year ago

Is there an existing issue for this?

Describe the bug

I am working on a container build for an aspnetcore project in an azure devops pipeline. For better debugging I am trying to use a separate 'dotnet build' and 'dotnet publish' commands. That section of the container file looks like this.

RUN dotnet build --configuration Debug --no-restore --no-incremental --use-current-runtime \
    --verbosity=minimal

RUN dotnet publish --configuration Debug --no-build \
    --verbosity=minimal \
    {project csproj file location}

This is the error from the docker build task in ADO

/usr/share/dotnet/sdk/6.0.405/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(680,7): error : Manifest file at 'obj/Debug/net6.0/staticwebassets.build.json' not found.

This error is nearly identical to that found in another issue, https://github.com/dotnet/aspnetcore/issues/41149, but that issue was closed after the author found it was fixed but changing 'release' to 'Release', but that does not seem to be relevant here. I confirmed the same result with either Debug or Release. Combining the two commands as such works.

RUN dotnet publish --configuration Debug \
    --verbosity=minimal \
    {project csproj file location}

.NET Version

6.0.405

mkArtakMSFT commented 1 year ago

Thanks for contacting us. Does this repro for a .NET 7 project? Also, please share a repro project, if the answer to the above question is yes.

ghost commented 1 year ago

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimalistic repro project that illustrates the problem.

pcappaert commented 1 year ago

Here is a repro project, https://github.com/pcappaert/WebApplication1. I am running on an m1 mac using Podman instead of docker. I did not encounter this issue when using the Debug configuration for the build and publish but I got the exact same error as I was seeing in ADO when I changed the configuration to Release so that is what I have in the repository. Here is the output from the container build for the publish step.

[1/2] STEP 12/12: RUN dotnet publish --configuration ${DOTNET_CONFIG} --no-build     --verbosity=normal     WebApplication1/WebApplication1.csproj
MSBuild version 17.3.2+561848881 for .NET
Build started 01/09/2023 16:26:18.
     1>Project "/source/WebApplication1/WebApplication1.csproj" on node 1 (Publish target(s)).
     1>PrepareForBuild:
         Creating directory "/source/WebApplication1/obj/Release/net6.0/refint/".
         Creating directory "obj/Release/net6.0/ref".
       PrepareForPublish:
         Creating directory "bin/Release/net6.0/publish/".
       ResolveStaticWebAssetsConfiguration:
         Creating directory "obj/Release/net6.0/staticwebassets/".
     1>/usr/share/dotnet/sdk/6.0.405/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(680,7): error : Manifest file at 'obj/Release/net6.0/staticwebassets.build.json' not found. [/source/WebApplication1/WebApplication1.csproj]
     1>Done Building Project "/source/WebApplication1/WebApplication1.csproj" (Publish target(s)) -- FAILED.

Build FAILED.

       "/source/WebApplication1/WebApplication1.csproj" (Publish target) (1) ->
       (_CleanupReferencedProjectItemGroups target) -> 
         /usr/share/dotnet/sdk/6.0.405/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(680,7): error : Manifest file at 'obj/Release/net6.0/staticwebassets.build.json' not found. [/source/WebApplication1/WebApplication1.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:05.29
Error: building at STEP "RUN dotnet publish --configuration ${DOTNET_CONFIG} --no-build     --verbosity=normal     WebApplication1/WebApplication1.csproj": while running runtime: exit status 1
ghost commented 1 year ago

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

mkArtakMSFT commented 1 year ago

@pcappaert can you also confirm if this repros for .NET 7?

pcappaert commented 1 year ago

yes, I see the same error when I update the repro project and Containerfile to use .NET 7

jspuij commented 7 months ago

Its unfortunate that this issue has not been solved yet for razor SDK projects, but it seems that in .NET 8 these build targets are moved to the regular .NET SDK. This means that non-blazor projects in our build pipeline need to be rebuilt as well. This adds considerably to our build times. Is there a way to work around this, or could this issue be resolved in the near future?

Relevant logs:

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/src/server/Nocore.PayrollEngine.ResthookService/Nocore.PayrollEngine.ResthookService.csproj]

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/src/server/Nocore.PayrollEngine.ProformaService/Nocore.PayrollEngine.ProformaService.csproj]

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/src/server/Nocore.PayrollEngine.WebService/Nocore.PayrollEngine.WebService.csproj]

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/src/server/Nocore.PayrollEngine.ReportingService/Nocore.PayrollEngine.ReportingService.csproj]

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/src/server/Nocore.PayrollEngine.EventHandler/Nocore.PayrollEngine.EventHandler.csproj]

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/doc/Nocore.PayrollEngine.Docs.WebServer.csproj]

MSBuild version 17.9.6+a4ecab324 for .NET

/usr/share/dotnet/sdk/8.0.203/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/Microsoft.NET.Sdk.StaticWebAssets.References.targets(16,5): error : Manifest file at 'obj/Release/net8.0/linux-x64/staticwebassets.build.json' not found. [/opt/atlassian/pipelines/agent/build/src/server/actors/Nocore.PayrollEngine.PayrollJobActor/Nocore.PayrollEngine.PayrollJobActor.csproj]

Edit: A workaround is to add the tag below to the projects you want to publish that do not use static web assets:

<StaticWebAssetsEnabled>false</StaticWebAssetsEnabled>