0

I use a hosted build agent via Visual Studio Team Services (previously Visual Studio Online) for ALM to carry out my build definition, which takes my 'beta' branch from GitHub and deploys it to my 'beta' deployment slot on an Azure WebApp. Every goes fine, except for one file - a simple .cshtml file called snapshot.cshtml. It uploads the accompanying snapshot.js file, but the snapshot.cshtml file is nowhere to be found in the build logs.

no sign of the cshtml file but there is the js and all other cshtml file my solution needs

This means despite a successful build my testers hit this:

The view '~/App/tenant/views/webitems/snapshot.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/App/tenant/views/webitems/snapshot.cshtml

I go in via FTP and discover that the message is indeed accurate:

everything else went up but not snapshot.cshtml

Workaround would be to upload the missing file, but obviously not ideal in a continuous deployment scenario.

Closer inspection of the .csproj file reveals an interesting difference:

who put that there

I didn't do this. Looking back at Blame in GitHub (still getting to grips with GitHub) I can see it just set it like that when the file was first created:

two different ways

It added snapshot.js fine as I wanted, but decided to set the Build Action for snapshot.cshtml to None for some unknown reason.

So whilst I hope others might find this post helpful, the question ultimately becomes how/why does it do that in the first place and how can I stop it from doing it again?

Esther Fan - MSFT
  • 8,276
  • 4
  • 27
  • 25
Mike Rouse
  • 1,278
  • 18
  • 34

1 Answers1

1

The file won't be included in the deployment package when the build action of it is set to "None" just as you found. Change the build action to "Content" will fix this issue.

To avoid this issue, you can add a custom target in your project file to check the build action of .cshtml files. Refer to the answer in this question for details: Make sure all *.cshtml files are set to be “Content” for Build Action.

Community
  • 1
  • 1
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60