EscapeTextForRegularExpressions error while webdeploying to azure - azure

In my asp.ent MVC4 project, I am using webdeploy to deploy to azure and I deployed this project to the app service on azure several times before. but out of a sudden I have this error.
"EscapeTextForRegularExpressions" task was not given a value for the required parameter "Text"
I Have found an answer:
Add this file into the web project in its root folder.
File Name : *.wpp.targets
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ExcludeFromPackageFolders Include="Internal">
<FromTarget>*.wpp.targets</FromTarget>
</ExcludeFromPackageFolders>
</ItemGroup>
</Project>
Never the less I cannot understand the real cause of the problem

According to your description, I found a similar issue noted the IncludeIisSettings within *.csproj. Per my test, if I specified the <IncludeIisSettings>true</IncludeIisSettings> with my csproj, then when I use the Web Deploy method from the Publish wizard of VS, I could encounter the similar issue as follows:
After remove the IncludeIisSettings or set the value to false, then I could deploy my web application to azure web app successfully.

I have another answer maybe can help someone:
You must open the Solution explorer then right-click the project, select properties, on Package/Publish Web check your Configuration is on Release and not on Active (Debug) in the drop-down, this was the solution in my case.

Related

Azure - Web deployment task failed. An error was encountered when processing operation 'Delete Directory' on (Application Insights)

I'm using Right-Click publish in Visual Studio to publish directly to my staging slot in Azure. I've added Application Insights that added a WebJob to my app.
I have enabled Remove additional files at destination and Precompile during Publishing turned on.
But when a Web Job is running and my staging site is not 'stopped', because it's still warmed up - I get the following error:
Web deployment task failed. ((18-Jan-18 22:47:23) An error occurred
when the request was processed on the remote computer.)
(18-Jan-18 22:47:23) An error occurred when the request was processed
on the remote computer. An error was encountered when processing
operation 'Delete Directory' on
'D:\home\site\wwwroot\App_Data\jobs\continuous'. The error code was
0x80070091. The directory is not empty.
at
Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode
errorCode, String maybeFullPath) at
Microsoft.Web.Deployment.DirectoryEx.Delete(String path) at
Microsoft.Web.Deployment.DirPathProviderBase.Delete(Boolean
whatIf) ProjectX.Web 7 0
I can fix this by manually stopping the staging slot, upload it, and then start it again. This is quite cumbersome though.
Is there a fix?
I read somewhere that you can automatically take the (staging) app offline during publish but I can't find the setting.
UPDATE 1
<PropertyGroup>
<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>
</PropertyGroup>
...is not working for me.
UPDATE 2
Adding the WEBJOBS_STOPPED setting on the Staging slot is not working for me.
As you have enabled Application Insights on your Azure App Service, it has internally installed an extension which started a continuous web job and content corresponding to web job got copied to App_Data folder. The actual problem is because extension data get copied to App_Data folder where only user's data should reside instead of infrastructure data.
Now when you are selecting the option "Remove Additional Files From Destination" in visual studio, it tries to remove all contents including Application Insights data from App_Data folder. Since Application Insights web job is already running in background hence corresponding dll files are locked.
Even if you go with option of "App Offline" or "Stop web job" and successfully able to delete all contents then your deployment will succeed but this way your Application Insights will get corrupted and hence you may have to configure Application Insights again.
Suggestion:
Select skip "App_Data" folder along with option "Remove Additional Files From Destination".
It will delete all content except App_Data folder content and hence dll files corresponding to Application Insights continuous web job will be skipped.
Reference :
VSTS - Azure App Service Task Documentation
Limitation
Though this solution have a limitation - If you want to remove/modify existing user defined web jobs then can't skip App_Data folder. In such case either have to perform two step deployment or have to reinstall application insight extension again.
I found this in another SO question:
<PropertyGroup>
<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>
...
</PropertyGroup>
... adding to your publishing profile (.pubxml).
The full answer is here: https://stackoverflow.com/a/20888597/647845
UPDATE
This is not working for me. Maybe for others. Seems to ignore the setting.

Error WAT200: No default service configuration "ServiceConfiguration.cscfg" could be found in the project

After installing Visual Studio Enterprise 2017 (Version 15.1 (26403.7)) my Azure Cloud Service does no longer build and gives me the 'Error WAT200: No default service configuration "ServiceConfiguration.cscfg" could be found in the project'. Although it still works fine with Visual Studio Enterprise 2015. (The right TargetProfile is also specified...)
I ran into this last night.
It actually happens when you rename Cloud Service configurations away from Cloud and Local.
In my case, I had deleted the Cloud configuration and created a new, differently named one.
By ensuring that the configurations are called Cloud and Local, the Cloud Service projects will build again using "Resharper build", and (most likely) under "Lightweight solution load".
The configurations can be renamed by right-clicking one of the service roles under the Cloud Service node in Solution Explorer, choosing Properties, then opening up the "Service Configuration" dropdown and clicking <Manage...>.
Now, in the resulting dialog, the configurations can be renamed:
The following bug report got me on the right track:
https://youtrack.jetbrains.com/issue/RSRP-450390
The best way is to change the service configuration prefix in ccproj of your project, add yourprojectname.configurationname
Dot is the life saver.
<ServiceConfigurationPrefix>yourproject.ServiceConfiguration</ServiceConfigurationPrefix>
Add these in itemgroup:
<ServiceDefinition Include="yourproject.ServiceDefinition.csdef" />
<ServiceConfiguration Include="yourproject.ServiceConfiguration.cscfg" />
Make sure you have renamed your cscfg files from the folder it resides.
Reload
Bingo. It works.
Ok I found it, after disabling the 'Lightweight Solution Load' (which in VS 2017 u can disable by right click on the Solution and then Disable Lightweight Solution Load), the error disappears and the Cloud Service builds again.
Similar to Rishikesh mentioned, but I added a service config entry
<ServiceConfiguration Include="ServiceConfiguration.cscfg" />
to the ccproj. Then copied a configuration, e.g. Production and named it ServiceConfiguration.cscfg. Then reloaded the project. That got the ReSharper to build, but MORE importantly for me at the moment was to figure out how to the get Azure DevOps pipeline to build the solution with multiple Classic WebRole projects in it. That was failing for the SAME reason.

VS 2013 Azure Publish hangs with last Pubxml file

If I publish to Azure Cloud Service using the Cloud Project and follow the publish wizard from it works fine but only if I delete the last Pubxml file (stored in the profile folder) first.
If I try and publish when a Pubxml file already exists it will hang trying to navigate between wizard steps.
Using SDK V2.9.6, although had the same issue on previous versions.
I have multiple subscriptions, and the issue seems to be whilst the Pubxml does store the subscription, it is ignored and the default (first one in the list alphabetically) is used instead.
So if I run a publish where there was a previous Pubxml, it jumps to the Diagnostics page. I click next for the summary and the issue areas are highlighted with a red error indicator (it has the wrong subscription selected by default, and hence it cannot find the correct cloud service). However I cannot click back as it just hangs.
I'm using SDK V2.9.6, and didn't see this problem. Actually, my pubxml files have subscription information included.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AzureCredentials>{"ServiceManagementEndpoint":"https:\/\/management.core.windows.net\/","ResourceManagementEndpoint":"https:\/\/management.azure.com\/","SubscriptionId":"my-subscription-id"}</AzureCredentials>
...
</PropertyGroup>
</Project>
Which version of Azure SDK is your pubxml files generated from?

Web deployment task failed with configuration: debug

I get the following error:
Web deployment task failed. (Could not complete an operation with the specified provider ("appHostConfig") when connecting using the Web Management Service. This can occur if the server administrator has not authorized the user for this operation. appHostConfig http://go.microsoft.com/fwlink/?LinkId=178034 Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER.)
When I try to publish my project to Azure with "Configuration: Debug". If I use "Configuration: Release" there are no problems.
I have tried deleting and recreating the Azure website and re-installing the SDK.
I followed a tutorial to setup Azure so I think it is unlikely that I setup something wrong.
I've googled around and found people with a similar error however they don't seem to have a relation to the Debug/Release configuration...
It did worked!
But, just for making things easier, you can right-click in your project, and at properties, go to Package/Publish web and Unckeck the option
"Inculde IIS Settings as configured in IIS Express"
Remember (important!) you are in the right configuration (combo at the top) Release/Debug you are trying to publish.
I got the same error ERROR_USER_NOT_AUTHORIZED_FOR_DEPLOYMENTPROVIDER in VS2013 while deploying to Windows Azure Websites (WAWS) and nothing nowhere to find to fix it.
It just so appears that my project deploys just great again after comparing the project file with a brand new one and finding the following difference, which I commented out to get it working again:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<!--<IncludeIisSettings>true</IncludeIisSettings>-->
</PropertyGroup>
So, right click the project and click Unload Project, right click it again and click Edit project.csproj and find the PropertyGroup with the condition matching whatever you're trying to deploy (Release|AnyCPU in this case) and make sure that line is commented out.

creating automatic backup when webdeploying

So what I want is that whenever i deploy from my dev-machine to the server-machine that an automatic backup of the current files for the site gets backuped.
I followed this guide for the configuration
http://www.iis.net/learn/publish/using-web-deploy/web-deploy-automatic-backups
At the root-level in IIS at the server this is configured
Using PowerShell on the server and calling
.\msdeploy.exe -verb:sync -source:backupManager -dest:backupManager=SiteName
will indeed create a backup of the site to the location D:\Websites\backups\SiteName_snapshots however no backup gets generated when I'm webdeploying from my dev-machine to the server.
I'm using Visual Studio 2012 for the publishing using a profile that is using an administrator account located at the targeted server.
According to this link:
Setting up automatic backups in Web Deploy tool
This feature seems broken in VS2010, is this still the case for VS2012?
Be sure to set EnableMSDeployBackup to True in your *.pubxml file
<Project>
<PropertyGroup>
...
<EnableMSDeployBackup>True</EnableMSDeployBackup>
...
</PropertyGroup>
</Project>
I solved my problem by passing this parameter:
msbuild ... /p:EnableMSDeployBackup=true
Hope this helps

Resources