IIS WebDeploy using MS Build Fails with error MSB4044 -ConcatFullServiceUrlWithSiteName task - visual-studio-2012

In setting up a Jenkins deployment job, I kept running into this error when trying to deploy a Visual Studio 2012 Web project via the command line.
error MSB4044: The "ConcatFullServiceUrlWithSiteName" task was not given a value for the required parameter "SiteAppName"
For reference, here are the parameters that I used:
/p:Configuration=Release /t:Rebuild /p:VisualStudioVersion=11.0 /p:PublishProfile="DeployToDevServer"
/p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish
/P:AllowUntrustedCertificate=True /p:MSDeployPublishMethod=WMSvc
/p:MsDeployServiceUrl=https://devmachine.server.com:8172/MsDeploy.axd
/p:username=domainhere\adminuserhere /p:password=adminpasshere
Note: It would deploy just fine if I chose Publish... from inside the project.

After much googling, and finally comparing a project that would deploy with the one that wouldn't, I finally figured it out after I opened the .csproj files with a text editor and compared them.
In the project that worked, I found this section:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
And it had this line:
<DeployIisAppPath>Default Web Site/sitenamehere</DeployIisAppPath>
I added this same line to the non-working project, changed the sitename, and it worked.
Hope this helps someone else.

You could pass this DeployIisAppPath as parameter to Jenkins, like this:
p:DeployIisAppPath=Default Web Site/sitenamehere
This would allow you to have different sitenames on different machines. While in your example (with CSPROJ modification) you would be obliged to have one IIS site name on all target machines

Related

Cannot run PowerShell scripts in Azure Functions v2

I'm trying to write a Function App using .NET Core in Azure Functions v2. When using the Microsoft.Powershell.SDK package from Nuget (required for .NET Core PowerShell runtime) I cannot get Visual Studio to copy the System.Management.Automation library to the bin with my Function App.
This results in the following error:
System.Private.CoreLib: Exception while executing function: Function1. TestPowershellInFunction: Could not load file or assembly 'System.Management.Automation, Version=6.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. System.Private.CoreLib: Could not load the specified file.
I've reproduced this in an existing Azure Function and a new Solution by simply creating a Timer function and adding the following snippet:
PowerShell shell = PowerShell.Create();
IEnumerable<PSObject> result = shell.AddScript("Write-Output 'Hello, World!'").Invoke();
foreach(PSObject line in result)
{
log.LogInformation(line.ToString());
}
This works on a new Console App with the PowerShell Nuget installed, but when added to the Function App I get the error. I do notice that System.Management.Automation doesn't get put in the bin directory with a regular Console App but I'm not sure how to interpret this. I know it's a System library but I can't use it unless the Nuget is installed, so I don't know if this is a special case. In both scenarios I'm using v6.1.1 of the PowerShell Nuget.
Is this a known bug with Functions v2? Or am I missing something?
It's a known issue that Function can't load runtime assemblies([FunctionProject]\bin\Debug\netcoreapp2.1\bin\runtimes) correctly.
The workaround is to move assemblies to output dir bin manually. Right click on your function project and Edit <FunctionProject>.csproj. Add following items to achieve our goal.
<PropertyGroup>
<SDKVersion>6.1.1</SDKVersion>
<SDKPlatform>win-x86</SDKPlatform>
</PropertyGroup>
<ItemGroup>
<None Include="
$(USERPROFILE)\.nuget\packages\system.directoryservices\4.5.0\runtimes\win\lib\netcoreapp2.0\System.DirectoryServices.dll;
$(USERPROFILE)\.nuget\packages\system.management\4.5.0\runtimes\win\lib\netcoreapp2.0\System.Management.dll;
$(USERPROFILE)\.nuget\packages\system.management.automation\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\System.Management.Automation.dll;
$(USERPROFILE)\.nuget\packages\microsoft.management.infrastructure\1.0.0\runtimes\win10-x86\lib\netstandard1.6\Microsoft.Management.Infrastructure.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.commands.management\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Commands.Management.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.commands.utility\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Commands.Utility.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.commands.diagnostics\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Commands.Diagnostics.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.sdk\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.SDK.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.security\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Security.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.coreclr.eventing\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.CoreCLR.Eventing.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.consolehost\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.ConsoleHost.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.markdownrender\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.MarkdownRender.dll;
$(USERPROFILE)\.nuget\packages\microsoft.wsman.runtime\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.WSMan.Runtime.dll;
$(USERPROFILE)\.nuget\packages\microsoft.wsman.management\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.WSMan.Management.dll;
">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="CopyRuntimeToBin" AfterTargets="Build">
<Copy SourceFiles="
$(USERPROFILE)\.nuget\packages\system.directoryservices\4.5.0\runtimes\win\lib\netcoreapp2.0\System.DirectoryServices.dll;
$(USERPROFILE)\.nuget\packages\system.management\4.5.0\runtimes\win\lib\netcoreapp2.0\System.Management.dll;
$(USERPROFILE)\.nuget\packages\system.management.automation\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\System.Management.Automation.dll;
$(USERPROFILE)\.nuget\packages\microsoft.management.infrastructure\1.0.0\runtimes\win10-x86\lib\netstandard1.6\Microsoft.Management.Infrastructure.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.commands.management\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Commands.Management.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.commands.utility\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Commands.Utility.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.commands.diagnostics\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Commands.Diagnostics.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.sdk\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.SDK.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.security\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.Security.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.coreclr.eventing\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.CoreCLR.Eventing.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.consolehost\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.ConsoleHost.dll;
$(USERPROFILE)\.nuget\packages\microsoft.powershell.markdownrender\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.PowerShell.MarkdownRender.dll;
$(USERPROFILE)\.nuget\packages\microsoft.wsman.runtime\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.WSMan.Runtime.dll;
$(USERPROFILE)\.nuget\packages\microsoft.wsman.management\$(SDKVersion)\runtimes\$(SDKPlatform)\lib\netstandard2.0\Microsoft.WSMan.Management.dll;
" DestinationFolder="$(OutputPath)\bin" />
</Target>
Note that microsoft.management.infrastructure is set to win10-x86 on my side(Win10), you may need to change according to your pc platform. Assemblies are x86 as VS uses x86 Function CLi by default, we don't need to worry about it unless we need to work with x64.

Web Deploy package throws ERROR_SITE_DOES_NOT_EXIST when deployed

After creating a WDP from an aspnet solution, the [project name].deploy.cmd file returns this error when executed:
Error Code: ERROR_SITE_DOES_NOT_EXIST
More Information: Site 'freedomstoreusa.azurewebsites.net' does not exist. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST.
Error count: 1.
My objective is to deploy the package to this site as if it were publishing to azure from visual studio 2017. What is causing this issue, what can resolve it and what are some alternatives to packaging and deploying a website?
Here are my settings in the package wizard:
what can resolve it and what are some alternatives to packaging and deploying a website?
I build and package the web application project, and use MSDeploy.exe to deploy the web application, which works fine on my side.
Command:
TestSite.SetParameters.xml
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="{app name}" />
</parameters>
I came here with the same problem but the image in the question and the answer from Fei Han solve my problem I was creating a File System Package not a Web Deploy Package which will create App.SetParameters.xml and the App.zip in the selected folder it also will ask for the app name an then you can use that auto generated file for the param -setParamFile:

Azure worker role gets published with the wrong service configuration

I'm trying to get the "publish to azure" functionality in VS2013 going for my worker-role cloud-service project.
The problem I'm having is that no matter what I change the service configuration settings to the application is always deployed with the Localservice configuration
My .azurePubxml:
<?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\/","SubscriptionId":"redacted"}</AzureCredentials>
<AzureDeleteDeploymentOnFailure>False</AzureDeleteDeploymentOnFailure>
<AzureDeploymentLabel>MyWorkerRole</AzureDeploymentLabel>
<AzureDeploymentReplacementMethod>AutomaticUpgrade</AzureDeploymentReplacementMethod>
<AzureSlot>Staging</AzureSlot>
<AzureEnableRemoteDesktop>True</AzureEnableRemoteDesktop>
<AzureEnableWebDeploy>False</AzureEnableWebDeploy>
<AzureFallbackToDeleteAndRecreateIfUpgradeFails>False</AzureFallbackToDeleteAndRecreateIfUpgradeFails>
<AzureHostedServiceLabel>MyLabel</AzureHostedServiceLabel>
<AzureHostedServiceName>MyService</AzureHostedServiceName>
<AzureEnableIntelliTrace>False</AzureEnableIntelliTrace>
<AzureEnableProfiling>False</AzureEnableProfiling>
<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
<AzureStorageAccountLabel>webstorage</AzureStorageAccountLabel>
<AzureStorageAccountName>webstorage</AzureStorageAccountName>
<AzureAppendTimestampToDeploymentLabel>True</AzureAppendTimestampToDeploymentLabel>
</PropertyGroup>
</Project>
As you can see, the AzureServiceConfiguration is set to Staging.
If i look at the output from the build I can see these lines:
Target "ResolveServiceConfiguration" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets" from project "path-to.ccproj" (target "CoreResolveServiceModel" depends on it):
3> Task "Message"
3> Target Profile: Local
3> Task "Message"
3> Service Configurations: ServiceConfiguration.Staging.cscfg;ServiceConfiguration.Production.cscfg;ServiceConfiguration.Local.cscfg
3> Task "Message"
3> Looking for a service configuration file named: ServiceConfiguration.Local.cscfg
3> Task "FindInList"
3> Task "Message"
3> Source Service Configuration: ServiceConfiguration.Local.cscfg
3> Task "Message"
3> Target Service Configuration: bin\Staging\ServiceConfiguration.cscfg
The end-result is that the ServiceConfiguration.Local.cscfg is used in the deployment instead of ServiceConfiguration.Staging.cscfg.
What does work though is to change the Service Configuration setting to staging under Development->Run/debug.
But this setting controls which configuration file is used when I run the app locally, so naturally I don't want to mess with it.
Also, if I use the Project->Package... option and choose staging I get the correct package and the correct config file generated.
I've also tried bulding manually with msbuild from commandline, works great as well.
Tried updating to azure sdk 2.6 in hopes that it would solve it, but no difference.
Should also say that I have this working in my web-role project. But for external reasons I had to split the worker-role to its own cloud project.
Update Some more info, I took a another closer look at the build log and found this:
1>------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
1>Build started 6/5/2015 5:15:03 PM.
1>Building with tools version "12.0".
1>Target "_CheckForInvalidConfigurationAndPlatform" in file "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets" from project "path_to_project.csproj" (entry point):
1>Task "Error" skipped, due to false condition; ( '$(_InvalidConfigurationError)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Task "Warning" skipped, due to false condition; ( '$(_InvalidConfigurationWarning)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Using "Message" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Message"
1> Task Parameter:Text=Configuration=Debug
1> Task Parameter:Importance=Low
1> Configuration=Debug
So it seems that neither
<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
from the .azurePubxml are actually being used as input to the build script.
It all seems to boil down to, where is the Publish to Azure function pulling its parameters from, if not from the .azurePubxml file?
Never got this working fully in VS2013 but now I've gone up to VS2015 and publish to Azure works as expected again.

VS 2012 Publishing Profiles and Copy Files Using MSBuilld Commands

I've set up asp.net website on Azure with TFS online for source control using VS 2012. I'm trying to copy files using VS 2012 new publishings profiles and MSBuild. Reading this article Visual Studio 2012 Web Deployment Projects are Dead – Long Live Publishing Profiles, in which Doug says you can use build scripts in your publishing profile.
So I setup a test that works in my .csproj on my local build. I'm just simply copying the robots.txt file from the root directory to the css directory. Here is my test. I set my pubxml in the TFS Build Process template under process > 6. Publishing -- Azure Website, Web Deploy Pubish Profile.
<Target Name="AfterBuild">
<Copy SourceFiles="$(ProjectDir)robots.txt" DestinationFolder="$(ProjectDir)css\" />
</Target>
I dropped this Code into my my pubxml file and I get a big nothing. What am I doing wrong?
Is it possible to copy files afterbuild on Azure?
Additional Information
The log file contains these lines so I'm sure the publishing profile is running.
AfterBuild:
Creating directory "C:\a\src\...\css".
Copying file from "C:\a\src\...\robots.txt" to "C:\a\src\...\css\robots.txt".
Here are the build steps that Azure's default build template uses:
ValidateSolutionConfiguration:
PrepareForBuild:
CoreCompile:
_CopyFilesMarkedCopyLocal:
CopyFilesToOutputDirectory:
GenerateTargetFrameworkMonikerAttribute:
CoreCompile:
_CopyFilesMarkedCopyLocal:
CopyFilesToOutputDirectory:
_CopyWebApplicationLegacy:
ValidateGlobalPackageSetting:
CollectFilesFromIntermediateAssembly:
CollectFilesFromContent:
CollectFilesFromIntermediateSatelliteAssembliesWithTargetPath:
CollectFilesFromReference:
CollectFilesFromAllExtraReferenceFiles:
CollectFilesFrom_binDeployableAssemblies:
PipelineCollectFilesPhase:
ExcludeGeneratedDebugSymbol:
PreTransformWebConfig:
TransformWebConfigCore:
PostTransformWebConfig:
PreProfileTransformWebConfig:
PipelineTransformPhase:
ProcessPublishDatabaseSettings:
PreAutoParameterizationWebConfigConnectionStrings:
AutoParameterizationWebConfigConnectionStringsCore:
PostAutoParameterizationWebConfigConnectionStrings:
PipelineMsdeploySpecificTransformPhase:
ValidatePublishProfileSettings:
CopyAllFilesToSingleFolderForMsdeploy:
PipelineCopyAllFilesToOneFolderForMsdeploy:
Package:
GenerateMsdeployManifestFiles:
PackageUsingManifest:
GenerateSampleDeployScript:
PipelineDeployPhase:
AfterBuild:
So it looks like Azure packages all the files up during the "31. CopyAllFilesToSingleFolderForMsdeploy" step. It would appear that running copy during the AfterBuild step is to late. I moved the Copy command to the target "BeforeBuild" but the files are still not ending up in the CopyAllFilesToOneFolderForMsdeploy step.
Thanks to Sayed Ibrahim Hashimi for his article How to compress CSS/JavaScript before publish/package for helping me solve this.
It's possible to copy directly Package Temp Directory. I ended up adding this target to my publishing profile (pubxml) file. After the "CopyAllFilesTOSingleFolderForMsdeploy" step finishes this step will run which will copy a file from one part of the solution into the destinationfolder you specify.
<Target Name="AdditionalFilesForPackage" AfterTargets="CopyAllFilesToSingleFolderForMsdeploy">
<Copy SourceFiles="$(ProjectDir)robots.txt" DestinationFolder="$(_PackageTempDir)\css\" />
</Target>

Cruisecontrol.net with UCM Clearcase - How to?

I am trying to configure Cruisecontrol.net for UCM Clearcase for the first time. Following is the sourceControl tag in the ccnet.config file:
<sourcecontrol type="clearCase">
<branch>123_India_Release</branch>
<autoGetSource>true</autoGetSource>
<viewName>admin_123_CRUISE</viewName>
<viewPath>$(ViewDirectory)</viewPath>
<useLabel>false</useLabel>
<useBaseline>false</useBaseline>
<executable>cleartool.exe</executable>
</sourcecontrol>
I constantly receive the following error:
ThoughtWorks.CruiseControl.Core.CruiseControlException: Source control
operation failed: cleartool: Error: Not an object in a vob: "PATH TO
THE VIEW"
When I run cleartool from an arbitrary directory with the following parameters:
cleartool.exe lshist -r -nco -branch "123_India_Release" -since
05-Dec-2012.14:38:18 -fmt
I get the same error. But if I change the working directory to $(ViewDirectory) before running cleartool, it runs fine.
How should I make Cruisecontrol.net run cleartool.exe from the $(ViewDirectory)?
I have already tried adding <workingDirectory>$(ViewDirectory)</workingDirectory> tag before <executable>cleartool.exe</executable> but it did not work.
Any help would be appreciated.
EDIT 1:
As a workaround I have done the following:
<exec>
<executable>cleartool.exe</executable>
<baseDirectory>d:\Workspace\123_India_Release\VOB</baseDirectory>
<buildArgs>update -force</buildArgs>
<buildTimeoutSeconds>6000</buildTimeoutSeconds>
</exec>
I have added this to the tasks tag. I have configured an hourly trigger which does the following:
1) Update snapshot view
2) Build the VS 2010 solutions mentioned in the tasks tag.
The limitations are:
1) The trigger is hourly. I want it to be a commit based trigger.
2) This is a workaround
EDIT 2:
Further experimentation revealed that the ccnet.exe works fine. It does all that is needed. The issue is caused by the service ccservice.
I have stopped ccservice for now and started ccnet.exe. I plan to leave it running.
The View directory isn't enough: you must specify a vob.
See for instance:
"clearfsimport: Error: Not an object in a vob: "\"." (as an illustratio of that error message)
this thread (or this one): "You have to specify explicitly the VOB(s) to check for modification set"
The path should looks like:
<viewPath>Drive:\path\to\view\vobname</viewPath>
If your $(ViewDirectory) already references Drive:\path\to\view, then you could use:
<viewPath>$(ViewDirectory)\vobname</viewPath>

Resources