Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

404 files when publishing to azure using github CI but only the first time. Redeploy same commit works. #2277

Closed
Bartmax opened this issue Dec 19, 2016 · 20 comments

Comments

@Bartmax
Copy link

Bartmax commented Dec 19, 2016

copied from: dotnet/aspnetcore#1879

I'm using ASPNET Core with grunt,bower version 1.1 (using project.json)
Every time I push to master, a build is triggered (configured on azure CI portal).

The first time, it publish successfully but all js and css are missing. (took like 10 mins to publish) (no files on disk and 404 errors) [grunt failed??]

Then I click on redeploy on azure portal (without touching anything from code) (it took a little less than previous one) and the second time it publishes successfully.

Note: I already published this way like 20 times, 18 out of 20 got the error but not always.
Note2: I never had to redeploy more than once. Everytime it fails, I click redeploy and every go smoothly on the 2nd try.

I find it hard to "debug" this but it's getting very annoying since the build got more frequent. Any ideas?

@watashiSHUN
Copy link
Contributor

can you share your Web App name, directly or indirectly? I'll take a look at what's going on.

@Bartmax
Copy link
Author

Bartmax commented Dec 19, 2016

this one: dummyfordiscovery

@colltoaction
Copy link

I'm experiencing a similar issue. Since around 2 weeks I need to deploy twice to get my changes live. I'm using VS 2017 csproj without any special configuration.

@watashiSHUN
Copy link
Contributor

watashiSHUN commented Dec 21, 2016

@Bartmax I tried to build your project locally in my VS2015, but it failed at restoring packages...

bower [package name]#^1.0.8     ENORESTARGET No tag found that was able to satisfy ^1.0.8
Additional error details:
No versions found in [git url]

it looks like there is an issue with bower, but my Azure deployment is successful, I wasn't able to reproduce your issue...

Note: I already published this way like 20 times, 18 out of 20 got the error but not always.

what exactly is the error message you are seeing, mine just shows Deployment successful

@Bartmax
Copy link
Author

Bartmax commented Dec 21, 2016 via email

@Bartmax
Copy link
Author

Bartmax commented Dec 21, 2016 via email

@davidebbo
Copy link
Member

@Bartmax I edited @watashiSHUN's entry.

@watashiSHUN
Copy link
Contributor

watashiSHUN commented Dec 22, 2016

My bad,
so I looked at your project build, the problem is that you construct wwwroot\ folder during the publish process (prepublish), but its not being picked up by dotnet publish...my theory is that it checks your "publishOptions":{"include":["wwwroot"]} in project.json, if the folder does not exist, it simply removes it from the list, then it runs the prepublish scripts followed by copy commands

so that every time you push to Azure, wwwroot\ folder will be created under website repository during publish but only when you redeploy (republish), it will be copied...since the second time, file existence test will pass

it's just a theory, not confirmed yet. But for now, your easiest workaround it simply change your project.json :

   "scripts": {
     "prepare": "...",
-    "prepublish": [ ... ],     //from this
+    "postcompile": [ ... ],    //to this

[Edit]
or add an empty wwwroot\ folder

@Bartmax
Copy link
Author

Bartmax commented Dec 22, 2016

thank you @watashiSHUN, sounds very reasonable. I'll try that workaround and see if that helps.

@Bartmax
Copy link
Author

Bartmax commented Mar 31, 2017

@watashiSHUN now that we are in csproj land. Is there any alternative for this to work? Can something be done on csproj ?

@watashiSHUN
Copy link
Contributor

you mean prepublish and postcompile? , I believe .csproj has some options: this and this.

@Bartmax
Copy link
Author

Bartmax commented Mar 31, 2017

@watashiSHUN no, those options behave exactly the same as project.json. I was thinking about something about include content but i figured that my folder is not on source control, so I added a .gitignore file inside wwwroot and included the empty folder on source control. I just saw your edit:

or add an empty wwwroot\ folder

hope that fixes it :)

@Bartmax
Copy link
Author

Bartmax commented Mar 31, 2017

@watashiSHUN mm. having an empty wwwroot on source control does NOT fixed the publish issue. I still have to redeploy twice to get assets. Why that would be the case?

@watashiSHUN
Copy link
Contributor

looks like "dummyfordiscovery" is no longer available, can you share another one?

@Bartmax
Copy link
Author

Bartmax commented Mar 31, 2017

created dummyfordiscovery again.

@watashiSHUN
Copy link
Contributor

How did you add the wwwroot folder? I don't see that commit in the git logs. Here's what I tried:

  1. add an empty file src/yourProject.Web/wwwroot/.gitkeep
  2. edit the .gitignore:
-wwwroot/
+wwwroot/*
+!wwwroot/.gitkeep

after pushing to Azure, I verify the existence of D:\home\site\wwwroot\wwwroot>

@Bartmax
Copy link
Author

Bartmax commented Mar 31, 2017

image

mmmm weird, it's there on the repo

@watashiSHUN
Copy link
Contributor

My mistakes, I was looking at your old project, I didn't realize that your repository is actually under D:\local. Unfortunately I am not an expert in dotnet core or msbuild. I am not sure why wwwroot is not copied(this does not look like a kudu bug), you probably need to edit your .csproj. I suggest you ask on stackoverflow

what I tried (and luckily worked) is this:

   <Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
     <Exec Command="npm install" />
     <Exec Command="bower install" />
     <Exec Command="gulp clean" />
     <Exec Command="gulp build" />
+       <ItemGroup>
+               <_CopyItems Include="wwwroot\**\*.*" />
+       </ItemGroup>
+       <Copy SourceFiles="@(_CopyItems)" DestinationFolder="$(PublishDir)\wwwroot\%(RecursiveDir)" />
   </Target>

you can do this kind of recursive copy at different stages of the build/publish life cycle, does that help?

@Bartmax
Copy link
Author

Bartmax commented Apr 1, 2017

@watashiSHUN I'll give it a try and let you know. i'm wondering why no one else seems to have this problem.

@jvano
Copy link
Member

jvano commented Apr 29, 2024

Hi

If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure:
https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

This way we can better track and assist you on this case

Thanks,

Joaquin Vano
Azure App Service

@jvano jvano closed this as completed Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants