Could not copy properties/launchSettings.json with docker and .Net Could not copy properties/launchSettings.json with docker and .Net (MSB3026, MSB3027, MSB3021)

Out of the blue, some of our docker builds stopped working with an error that it could not copy launchsettings.json when doing a build in our .net7.0 containers.

Could not copy "/src/api/properties/launchSettings.json" to "bin/Release/net7.0/properties/launchSettings.json". Beginning retry 1 in 1000ms. Could not find a part of the path '/src/api/bin/Release/net7.0/properties/launchSettings.json'

The only thing that has changed was that we added a submodule (and referenced the project) that uses Razor services. Something similar to this is mentioned in this github issue and this one … while not my particular case, it was clear that the Razor project was the issue.

This is quite strange as we have used that project in a number of other places and never had issue with it. I though that this was maybe a case sensitive issue, or maybe some other problem with this being a linux container on an arm mac… but no matter what I tried I couldn’t figure it out.

The step before this I dumped in the command RUN echo $(ls -1 /src/api/bin) to just show me what was there. While there was a Release folder, it was empty.

For some reason, including a Razor Pages project within another project (we use it for getting HTML templates from the .razor pages for email templates) was suddenly killing everything.

The solution? As stupid and simple as you think. Adding this line right at the top of the docker file solves the issue:

RUN mkdir -p src/api/bin/Release/net7.0/properties

Yup… just create the folder yourself manually and it is happy to copy files over to it no problem.

Small update to this… if you are running other things like unit tests, it seems you might need to create a few more folders:

RUN mkdir -p src/api/bin/Release/net7.0/properties
RUN mkdir -p src/api/bin/Debug/net7.0/properties
RUN mkdir -p src/tests/bin/Release/net7.0/properties
RUN mkdir -p src/tests/bin/Debug/net7.0/properties

Leave a comment

Blog at WordPress.com.

Up ↑