Building and Publishing on Azure Devops Failed - msbuild

I wanted to publish my project in Azure Devops pipeline but I encountered several errors.
I tried to publish one of the .csproj file of my solution (.sln) from VisualStudio2017 it worked perfectly but when I try it with Azure Devops pipeline then it shows the below error. I've googled everywhere but not able to find the correct solution to solve my error.
My pipeline looks like this
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\Node.js Tools\Microsoft.NodejsTools.targets(201,5): Error : web.config not found in project, to create a project to deploy to Microsoft Azure you must create an Azure Node.js project. Process 'msbuild.exe' exited with code '1'
Tried adding the basic web.config file even that doesn't work.

Building and Publishing on Azure Devops Failed
To resolve this issue, you can try a quick way to solve it is by creating a Blank Azure Node.js Web Application and copy-paste the web.config into your project.
Check more details on section "Converting to an Azure project type" of page: https://github.com/Microsoft/nodejstools/wiki/Publish-to-Azure-Website-using-Web-Deploy:
The easiest way to get them is to create a new temporary Azure project
type, such as:
Blank Azure Node.js Web Application Basic Azure Node.js Express
Application Starter Azure Node.js Express Application Basic Azure
Node.js Express 4 Application And copy the missing web.config and bin
folder from the new project to your existing project.
Note that in web.config, the starter .js file (app.js, server.js or
something else) appears a few times. Make sure that it matches your
starter file, otherwise your application won't run properly when it's
deployed on Azure.
Hope this helps.

Try to delete delete and create a new solution or override the existing solution.
Then build it locally and then, check-in & build in azure CI pipeline.
It worked for me hope it works for you too.

Related

VSTS Continuous Deployment of ASP.NET MVC Core 2.0 app to Azure Web Apps not deploying, no errors

No matter how many times I attempt to deploy my recently migrated ASP.NET MVC Core 2.0 app from VSTS CD, I only see old builds that were created before I migrated the project and VSTS CI build steps.
No error messages. Everything is making happy noises. However, I have the build number injected into the appsettings.json so I can see which build is in production, AND I've made several tiny aesthetic changes just to know for sure there's a new build of the software out on production and I am 100% confident the latest build is not being served.
I migrated my web app from ASP.NET MVC Core 1.1.2 to ASP.NET MVC Core 2.0.0. The last two successfully deployed 1.1 builds were #259 & #260.
I updated the VSTS build process using the "preview" 2.0 steps and got it producing successful builds. This new build is #270.
The VSTS release process reported no errors when deploying to Azure Web Apps Websites in a Staging slot.
I swap the slots without any errors.
However, I only see builds #259 and #260 as I try and re-try to re-release build #270 manually and re-swap the slots after VSTS CD gives me a successful response.
At this point, I'm considering going into Kudu and just deleting everything to force Azure Web Sites Web Apps to give me an obvious error message.
Before I do that, however, I wanted to ask if there's anything obvious I'm missing? Unlike the CI feature, VSTS CD has no verbose logging (AFAICT) and I can't locate any logging on Azure Web App's side regarding deployment attempts.
Here's a history of the builds ... all successful:
For context, here's the overall pipeline:
Here's the definition for Azure App Service:
Update 8/24 10am:
This morning, based on #starain-MSFT's comment, I did the following:
In Azure, I stopped both staging and production slots.
Back in VSTS in the release definition, in the "Azure App Service Deploy" task, I checked and yes, "Publish using Web Deploy" was already checked.
I added a checkmark to "Remove additional files at destination".
I created a new release (#110).
I check the logs for the "Deploy Azure App Service" release task:
2017-08-24T14:53:01.7169084Z ##[section]Starting: Deploy Azure App Service
2017-08-24T14:53:01.7419076Z ==============================================================================
2017-08-24T14:53:01.7419076Z Task : Azure App Service Deploy
2017-08-24T14:53:01.7419076Z Description : Update Azure Web App Services, Web App On Linux , Function Apps, Mobile Apps using Web Deploy / Kudu REST APIs
2017-08-24T14:53:01.7419076Z Version : 3.3.13
2017-08-24T14:53:01.7419076Z Author : Microsoft Corporation
2017-08-24T14:53:01.7419076Z Help : [More Information](https://aka.ms/azurermwebdeployreadme)
2017-08-24T14:53:01.7419076Z ==============================================================================
2017-08-24T14:53:03.7273244Z Got connection details for Azure App Service:'beastmuffin'
2017-08-24T14:53:04.4099686Z [command]"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package='d:\a\r1\a\BeastMuffin-CI\drop\270.zip' -dest:contentPath='beastmuffin',ComputerName='https://beastmuffin-staging.scm.azurewebsites.net:443/msdeploy.axd?site=beastmuffin',UserName='********',Password='********',AuthType='Basic' -enableRule:AppOffline -userAgent:VSTS_3ba069a5-b836-4fd5-9b7a-158f8f07399f_release_1_110_110_1
2017-08-24T14:53:05.4251931Z Info: Using ID '5285835e-1d30-414e-bcb6-288c207678ac' for connections to the remote server.
2017-08-24T14:53:16.2964958Z Info: Deleting file (beastmuffin\Accessibility.dll).
2017-08-24T14:53:16.2964958Z Info: Deleting file (beastmuffin\Accessibility.xml).
... about 3000 lines later ...
2017-08-24T14:54:43.0840845Z Info: Deleting file (beastmuffin\zh-Hant\System.Spatial.resources.dll).
2017-08-24T14:54:43.0840845Z Info: Deleting directory (beastmuffin\zh-Hant).
2017-08-24T14:54:43.0840845Z Total changes: 3009 (0 added, 3009 deleted, 0 updated, 0 parameters changed, 0 bytes copied)
2017-08-24T14:54:43.0980858Z Successfully deployed web package to App Service.
2017-08-24T14:54:44.9961584Z Successfully updated deployment History at https://beastmuffin-staging.scm.azurewebsites.net/deployments/1101503586484042
So, it looks like it deleted the old files, but did not deploy / add the new build's files to Azure -- HOWEVER the COMMAND to deploy (per the logs) did not throw any exceptions.
Just to confirm nothing really got deployed, I visit the site and see this now:
So, I'm guessing there's no files in the production slot at the moment.
Update 8/24 1pm:
One new pertinent detail as I continue to debug this.
The new (preview) App Service Editor shows that the .zip file has been moved to the /wwwroot folder, however it does not unzip it.
Based on the logs and the .zip file, I'm beginning to think that the "Deploy Azure App Service" task doesn't yet support ASP.NET MVC Core 2.0.
To that end, I've opened a support issue on the vsts-tasks GitHub repo:
https://github.com/Microsoft/vsts-tasks/issues/5111
This issue was resolved out on GitHub (github.com/Microsoft/vsts-tasks/issues/5111).
In a nutshell, the new Build step "dotnet publish" (under preview as I write this) allows you to zip up the artifacts.
However, I already had the old "archive files" build step that I never removed from the previous build definition for ASP.NET MVC Core 1.1.
So, the result was the build was zipping up the zipped publish. During release, the publish was unzipped once, leaving the inner zip file unzipped as it moved it to the Azure website destination.

How to deploy ASP.NET 5 app to Azure without triggering build in Azure with VS code

What is the best way to deploy the output of dnu publish to Azure website? I do not want build to trigger at the Azure side, because it takes forever and often breaks.
One trick i do is to exclude un needed folders such as bower or node packages or any other folders by adding it to the exclude configuration in project.json.
check out a reference for the project.json exclude list to follow: http://docs.asp.net/en/latest/dnx/projects.html#building
hope this helps.

VB.NET Azure deployment has no /bin but has a nuget package

I've just published (via GitHub) a VB.NET Azure Website that works fine on local machines but not on Azure:
Compiler Error Message: BC30451: 'Newtonsoft' is not declared. It may
be inaccessible due to its protection level.
Dim category As Category = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Category)(json)
The Newtonsoft.Json package is installed via NuGet: Newtonsoft.Json.5.0.5.
It's the only 3rd party dll in the project right now.
I used the Azure ftp access to browse to /site/wwwroot/ and noticed that there is no /bin directory.
Now, my .gitignore excludes [Bb]in and [Oo]bj folders, but it's the same .gitignore I've used successfully with c# projects and always assumed that Azure just fetches the missing nuget dlls from /packages.
This is my first VB.NET > GitHub > Azure Websites deployment. What have I missed?
edit: I can confirm that if I upload /Bin/Newtonsoft.Json.dll via Azure ftp the site works. Or at least it will until it's re-imaged...
Sounds like you've not enable "NuGet Package Restore".
By doing so this creates a .nuget folder at the root of your solution and a packages.config file in the application that the build process in Azure will pick up and load the required references from.
Right click on the solution and it should be an option in there.

TFS2010 Build does not deploy web application

I'm trying to get my web application to deploy automatically at the end of an automated build and I'm obviously missing something.
My setup is:
VS2012 on a Win7 workstation
TFS2010 repository on serverA
TFS build agent on serverB
Test site in IIS7 on serverC.
I have created a quick test project using the default MVC4 template and created a Team Project to go with it using the MS VS Scrum 1.0 template.
I created a new publish profile for the web application using the publish web dialog and the .pubxml file is checked in with the project. The .pubxml file looks something like this:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<SiteUrlToLaunchAfterPublish>TestServer/DeployTest</SiteUrlToLaunchAfterPublish>
<MSDeployServiceURL>http://TestServer</MSDeployServiceURL>
<DeployIisAppPath>webapp-dev/DeployTest</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>RemoteAgent</MSDeployPublishMethod>
<UserName>mydomain\myuser</UserName>
<_SavePWD>True</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="" />
</PublishDatabaseSettings>
</PropertyGroup>
</Project>
*some of the names have been changed to protect the innocent :)
Using this profile I can successfully publish the application from Visual Studio to the test web server without any issue. Following Scott Hanselman's blog post I successfully published from the command line on my workstation:
msbuild DeployTest.csproj /p:DeployOnBuild=true /p:PublishProfile=Test /p:AllowUntrustedCertificate=true /p:Password=notTheRealPassword
I then created a build in Team Explorer that would use my build server to compile and then run the unit tests. All good. The project builds, unit tests pass.
I then added the parameters from the command line to the MS Build Arguments in the Advanced section of the build definition:
/p:DeployOnBuild=true /p:PublishProfile=Test /p:AllowUntrustedCertificate=true /p:Password=notTheRealPassword
The build runs, the unit tests pass, nothing is published to the web server. :(
Can someone enlighten me as to what I have missed? Nothing I've read seems to indicate a step I have missed out but there's seemingly precious little documentation to explain how this is done.
It sounds like tfs might not support publish profiles.
You may need to pull out all the parameters from the profile and specify them manually.
Here's a similar question.
Team Build: Publish locally using MSDeploy
I know this is an old question but today I ran into the same issue and I think I know the reason for the behavior you observed. Let me summarize the issue:
You have create a web deploy publish profile.
When you use the profile from command prompt with MSBuild command, the site is published successfully.
But when you use this profile from the build definition (by specifying MS Build Arguments in the advanced section of the build definition) the site is not published.
I think the reason behind this is because you have VS 2012 on your workstation which supports publish using profile feature. Hence when you run the MS build from command prompt on your work-station the site is published. But the support for publish profile is not available on TFS 2010 hence with build server the site is not published.
I faced the same issue today and I did following to resolve the issue:
On TFS machine, from the command prompt, I ran the MS Build command with publish profile. The command ran successfully but nothing got published (copied) on the site. This proves that TFS 2010 server does not support public profiles.
I had VS 2010 deployed on the TFS machine. I installed web deploy 3.5 and Windows Azure SDK for Visual Studio 2010. This is the way to provide support for publish profile on VS 2010.
Then I ran the MS Build command using published profile from command prompt and it published the site successfully.
Then finally executed the build definition with MS Build parameters and the site got published successfully.
I know installing Visual studio on TFS machine not an ideal solution but at least it solved my problem.
I am also not sure why installing VS 2010 with publish profile support resolved the issue. But it seems that, after the installation some of the missing components/dlls got deployed on the TFS machine which resolved the issue.
Hope this resolves your deployment issue.
[UPDATE]: There could be another reason for the above behavior. Check the log messages of the build activity. If you find a warning similar to this:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (484, 9): warning: The OutputPath property is not set for project ProjectName.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Release' Platform='Any CPU'
Then it may be related to build configuration. If you are using “Any CPU” as build configuration then change it to “AnyCPU” (remove space). Refer following link for the detailed explanation:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/0bb277ec-a08c-4795-88f0-3207654e2560/the-outputpath-property-is-not-set-for-project-xxxxxbtproj-please-check-to-make-sure-that-you?forum=tfsbuild
Amey

Windows Azure - Microsoft.IdentityModel not found

I installed WIF runtime and SDK on my machine. I added Microsoft.IdentityModel.dll to my azure web application and locally everything is running great. I build simple web application which use Azure AppFabric Access control. I follow azure labs for that and as I told, local everything is great. When I published my web application to Azure, I'm getting following error :
Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I get it after Appfabric Relaying part is going to return url, after sign in on identity provider. The weird thing is that I set Copy Local to TRUE, because that .dll is not part of Azure GAC. I tried to publish it again, but I received same error. I found few same problems on the internet but with no concrete solution. Does anybody here had something similar and probably have a working solution? Thank you in advance
For anything that I need to deploy locally to Azure I make a copy of the DLL's in my project folder and reference them from there while setting copy local to true. Since doing this I no longer have any issues with DLL's not being published to Azure. I also do all of my building through the command line using MSBuild and publish the cspack by hand. This means that I do not rely on Visual Studio for doing the build or deployment.
I have run into this and solution described in this blog helped. You will need to run this command from your role startup task:
gacutil /nologo /i .\Microsoft.IdentityModel.dll
This startup task has to be run with full privilegies.
Have you tried disabling encryption on the creation of the deployment package and verifying that the dll is indeed present?
Create a new environment variable called: _CSPACK_FORCE_NOENCRYPT_ set the value to true.Restart your visual studio.