-
Notifications
You must be signed in to change notification settings - Fork 6k
Mention adding dockerignore file as resolution to NETSDK1047 #29530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mention adding dockerignore file as resolution to NETSDK1047 #29530
Conversation
Also see: https://stackoverflow.com/questions/49392196/assets-file-obj-project-assets-json-doesnt-have-a-target-vs2017/72298520#72298520 My answer below: I ran into the `NETSDK1047` when playing around with Docker in a brand new dotnet project created using `docker new worker` and the docker file from [dotnet-docker samples](https://github.com/dotnet/dotnet-docker/blob/3739ebf9f8fa2cc85eb3b73bc00fca467672771f/samples/dotnetapp/Dockerfile.alpine-x64-slim). ``` ❯ docker build -t dockertest . output elided... /usr/share/dotnet/sdk/6.0.300/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/source/obj/project.assets.json' doesn't have a target for 'net6.0/linux-musl-x64'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project. You may also need to include 'linux-musl-x64' in your project's RuntimeIdentifiers. [/source/dockertest.csproj] The command '/bin/sh -c dotnet publish -c release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true' returned a non-zero code: 1 dockertest on main [✘] via .NET v6.0.202 🎯 net6.0 ❯ ``` The issue was because I forgot to add a `.dockerignore` [file](https://github.com/willbush/dockertest/blob/08ef0c3cd7d984af20902245d9573fdf3601223b/.dockerignore) ignoring the `bin` and `obj` directories. I only realized why because I tried different Dockerfiles from the `dotnet-docker` repo and got a [different error](https://docs.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1064) which has this same resolution. I'll try to make a PR to the docs of `NETSDK1047` to add this resolution.
I'm unable to find where in code this error message originates in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution. I'm just suggesting a change to the link text.
Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>
…29530) * Mention adding dockerignore file as resolution to NETSDK1047 Also see: https://stackoverflow.com/questions/49392196/assets-file-obj-project-assets-json-doesnt-have-a-target-vs2017/72298520#72298520 My answer below: I ran into the `NETSDK1047` when playing around with Docker in a brand new dotnet project created using `docker new worker` and the docker file from [dotnet-docker samples](https://github.com/dotnet/dotnet-docker/blob/3739ebf9f8fa2cc85eb3b73bc00fca467672771f/samples/dotnetapp/Dockerfile.alpine-x64-slim). ``` ❯ docker build -t dockertest . output elided... /usr/share/dotnet/sdk/6.0.300/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/source/obj/project.assets.json' doesn't have a target for 'net6.0/linux-musl-x64'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project. You may also need to include 'linux-musl-x64' in your project's RuntimeIdentifiers. [/source/dockertest.csproj] The command '/bin/sh -c dotnet publish -c release -o /app -r linux-musl-x64 --self-contained true --no-restore /p:PublishTrimmed=true /p:PublishReadyToRun=true /p:PublishSingleFile=true' returned a non-zero code: 1 dockertest on main [✘] via .NET v6.0.202 🎯 net6.0 ❯ ``` The issue was because I forgot to add a `.dockerignore` [file](https://github.com/willbush/dockertest/blob/08ef0c3cd7d984af20902245d9573fdf3601223b/.dockerignore) ignoring the `bin` and `obj` directories. I only realized why because I tried different Dockerfiles from the `dotnet-docker` repo and got a [different error](https://docs.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1064) which has this same resolution. I'll try to make a PR to the docs of `NETSDK1047` to add this resolution.
It's here |
Summary
Note added resolution is similar to netsdk1064.
Here are repeatable steps to repro the issue:
Observe the error NETSDK1047 after the above command.
Adding
dockerignore
file to ignorebin
andobj
solves the error:Full console output