Docker Build Errors
Closed this issue · 4 comments
I am currently encountering an docker build error and I am not too sure exactly where the source of this issue would come from. I can see that the main.js file is not the one that dotnet is expecting to have. I have tried playing around with a few things to solve this, but I am not able to fix it so far. I have noticed that if you run "dotnet publish -c release" in windows cmd, "ng build" will run twice in a row, I do not know if this is by design or not, it may be.
This all could very well just be me doing something wrong, but I have not modified the app whatsoever from the github and from the dotnet template. The docker file is out of date for the dotnet template, but even the updated github repo fails and throws the same error when attempting to build.
Screenshot of the error message:
Any advice, help, or possible fixes would be greatly appreciated. This is an awesome project template that I would really love to use.
Well the main.*48c.js
in the error message doesn't match the main.*80c.js
that was generated so I'm assuming there's some sort of stale caching problem.
The source of this error comes from a Microsoft.NET.Sdk.Razor.StaticWebAssets.targets
MSBuild task which I'm not familiar with, is that something you've added yourself or are you just using the default template?
Actually it looks like the double build may have caused the issue so I've just removed it from this commit.
If you create a new project it should hopefully resolve this issue:
$ x new angular-spa ProjectName
Sorry it took a little while for me to respond, I was going to reply about 1 minute after you posted the update, but i decided to do the build a few times and make sure it didn't break. Sure enough, it still broke. However, I figured out the issue was that docker was copying the wwwroot from the project instead of using the newly built files.
Fix: Add a line in .dockerignore
*/wwwroot
this prevents docker from copying this whenever it copies the project, it solves the problem.
Also, A command you remove is required to build the angular,"npm install --also=dev" --- this needs to be added back
I do not know what that other command "npm run-script build" was doing, but everything works fine with it now that I figured out the issue. It still runs two ng builds if you have this though, so it seems unnecessary unless there is a specific purpose of that command.
Sorry the issue was something simple, I haven't had this happen in any other projects.
Thank you for your help.
Ok I was able to repro the issue during a publish and saw that it was building twice with the postinstall task so I removed it, but should've probably removed the other task.
npm run-script build
is the same as npm run build
which just runs the npm build task:
angular-spa/MyApp/package.json
Line 9 in c78a247
Which isn't necessary because after you run install the "postinstall" task which already runs the build:
angular-spa/MyApp/package.json
Line 5 in c78a247
Anyway I've swapped the build tasks and added the ignore tasks in this commit c78a247 which should hopefully resolve the issue.