VS 2012 Publishing Profiles and Copy Files Using MSBuilld Commands - azure

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>

Related

How can we deploy from TFS to IIS on shared hosting? (GoDaddy)

The documentation found here describes how to deploy to IIS, but the WinRM component requires local admin permissions. Obviously, this isn't going to be available on shared hosting with service providers such as GoDaddy. (We'll be excluding Azure targets for the purposes of this discussion.)
Visual Studio can do this very easily, simply by using an imported .publishsettings file. Doesn't it stand to reason that TFS should be able to do the same thing without needing the extra privileges?
...or are we simply out of luck when trying to use TFS to publish to non-Azure shared hosting configurations?
--EDIT--
I've been working on Patrick's suggested answer all day, and after countless combinations of configurations I'm still coming up empty. MSBuild does look like the way to go for this, yes, but I can't get it working on my TFS 2018.
The output from the Release task is below. As we can see, MSBuild refuses to publish the site to my local testing IIS.
The strange thing is that MSBuild publishes as expected when I run the command from the logs below from a command window on my local workstation (after adjusting for the relevant file paths, of course, and removing the /dl:CentralLogger switch).
One of the things I tried was to edit/delete files on the source/target, to try to force a sync. That didn't work either.
Does anyone see any indication why this isn't working?
Log
2018-02-27T04:48:38.4708105Z ##[section]Starting: Build solution $(System.DefaultWorkingDirectory)/Website/drop/Website.vbproj
2018-02-27T04:48:38.4938123Z ==============================================================================
2018-02-27T04:48:38.4938123Z Task : Visual Studio Build
2018-02-27T04:48:38.4938123Z Description : Build with MSBuild and set the Visual Studio version property
2018-02-27T04:48:38.4938123Z Version : 1.120.0
2018-02-27T04:48:38.4938123Z Author : Microsoft Corporation
2018-02-27T04:48:38.4938123Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613727)
2018-02-27T04:48:38.4938123Z ==============================================================================
2018-02-27T04:48:41.0024890Z ##[command]"D:\Agent\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.120.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2018-02-27T04:48:41.7115427Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe" "D:\Agent\_work\r5\a\Website\drop\Website.vbproj" /nologo /nr:false /dl:CentralLogger,"D:\Agent\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.120.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=6e6502d0-9bea-46af-a5a7-9dac551b9e29|SolutionDir=D:\Agent\_work\r5\a\Website\drop"*ForwardingLogger,"D:\Agent\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.120.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:DeployOnBuild=true /p:AllowUntrustedCertificate=true /p:PublishProfile="D:\Agent\_work\r5\a\Website\drop\My Project\PublishProfiles\QA.pubxml" /p:Password=******** /p:platform="AnyCPU" /p:configuration="release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="TFS_1c911c00-1ecd-4ca9-87b0-d8d34f8c59c4_release_2_24_24_1"
2018-02-27T04:48:42.3456044Z Build started 2/26/2018 7:48:42 PM.
2018-02-27T04:48:44.0457237Z Project "D:\Agent\_work\r5\a\Website\drop\Website.vbproj" on node 1 (default targets).
2018-02-27T04:48:44.0487239Z CoreResGen:
2018-02-27T04:48:44.0487239Z No resources are out of date with respect to their source files. Skipping resource generation.
2018-02-27T04:48:44.2587401Z CoreCompile:
2018-02-27T04:48:44.2597397Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\vbc.exe /noconfig /imports:Intexx,Intexx.Linq,Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.ComponentModel,System.Data,System.Data.Common,System.Data.Entity,System.Data.Entity.Migrations,System.Data.SqlClient,System.IO,System.Linq,System.Xml.Linq,System.Diagnostics,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls /optioncompare:Binary /optionexplicit+ /optionstrict:custom /nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 /optioninfer+ /nostdlib /rootnamespace:Website /sdkpath:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7" /highentropyva+ /doc:obj\release\Website.xml /define:"CONFIG=\"release\",TRACE=-1,_MyType=\"Custom\",PLATFORM=\"AnyCPU\"" /reference:D:\Agent\_work\r5\a\Website\drop\bin\EntityFramework.dll,D:\Agent\_work\r5\a\Website\drop\bin\EntityFramework.SqlServer.dll,D:\Agent\_work\r5\a\Website\drop\bin\Intexx.Core.dll,D:\Agent\_work\r5\a\Website\drop\bin\itxcorlib.dll,"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.ComponentModel.DataAnnotations.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Configuration.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Core.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Data.DataSetExtensions.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Data.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Drawing.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.EnterpriseServices.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Web.ApplicationServices.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Web.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Web.DynamicData.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Web.Entity.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Web.Extensions.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Web.Services.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Xml.dll","C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7\System.Xml.Linq.dll" /debug+ /debug:pdbonly /optimize+ /out:obj\release\Website.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /resource:obj\release\Website.Migrations._001.resources /resource:obj\release\Website.Resources.resources /target:library /utf8output App_Code\Enums.vb Bill.aspx.designer.vb Bill.aspx.vb Contact.aspx.designer.vb Contact.aspx.vb Default.aspx.designer.vb Default.aspx.vb Defects.aspx.designer.vb Defects.aspx.vb Donate.aspx.designer.vb Donate.aspx.vb Forum.aspx.designer.vb Forum.aspx.vb Jackson.aspx.designer.vb Jackson.aspx.vb Key.aspx.designer.vb Key.aspx.vb Laws.aspx.designer.vb Laws.aspx.vb Letters.aspx.designer.vb Letters.aspx.vb Losers.aspx.designer.vb Losers.aspx.vb Main.Master.designer.vb Main.Master.vb MenuItem.ascx.designer.vb MenuItem.ascx.vb Migrations\201802040108464_001.Designer.vb Migrations\201802040108464_001.vb Migrations\Configuration.vb Migrations\Defaults.vb Models\Db\Context.vb Models\Db\Loser.vb Models\Db\NewsItem.vb "My Project\AssemblyInfo.vb" "My Project\Application.Designer.vb" "My Project\MyExtensions\MyWebExtension.vb" "My Project\Resources.Designer.vb" "My Project\Settings.Designer.vb" News.aspx.designer.vb News.aspx.vb Oops.aspx.designer.vb Oops.aspx.vb Pocket.aspx.designer.vb Pocket.aspx.vb Seventeenth.aspx.designer.vb Seventeenth.aspx.vb States.aspx.designer.vb States.aspx.vb Store.aspx.designer.vb Store.aspx.vb "D:\Agent\_work\_temp\.NETFramework,Version=v4.7.AssemblyAttributes.vb"
2018-02-27T04:48:44.2917430Z Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn
2018-02-27T04:48:44.5307644Z
2018-02-27T04:48:44.5357653Z _CopyFilesMarkedCopyLocal:
2018-02-27T04:48:44.5357653Z Touching "D:\Agent\_work\r5\a\Website\drop\obj\release\Website.vbproj.CopyComplete".
2018-02-27T04:48:44.5567658Z CopyFilesToOutputDirectory:
2018-02-27T04:48:44.5577603Z Copying file from "obj\release\Website.dll" to "bin\Website.dll".
2018-02-27T04:48:44.5587611Z Website -> D:\Agent\_work\r5\a\Website\drop\bin\Website.dll
2018-02-27T04:48:44.5597611Z Copying file from "obj\release\Website.pdb" to "bin\Website.pdb".
2018-02-27T04:48:44.5607636Z Copying file from "obj\release\Website.xml" to "bin\Website.xml".
2018-02-27T04:48:44.5967639Z Done Building Project "D:\Agent\_work\r5\a\Website\drop\Website.vbproj" (default targets).
2018-02-27T04:48:44.6257666Z
2018-02-27T04:48:44.6257666Z Build succeeded.
2018-02-27T04:48:44.6257666Z 0 Warning(s)
2018-02-27T04:48:44.6257666Z 0 Error(s)
2018-02-27T04:48:44.6257666Z
2018-02-27T04:48:44.6257666Z Time Elapsed 00:00:02.29
2018-02-27T04:48:44.6868621Z ##[section]Finishing: Build solution $(System.DefaultWorkingDirectory)/Website/drop/Website.vbproj
QA.pubxml
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://www.website.local</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>https://server3:8172/msdeploy.axd</MSDeployServiceURL>
<DeployIisAppPath>website</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>DOMAIN\User</UserName>
<_SavePWD>True</_SavePWD>
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="Website.Db.Context" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Website.Db.Context, Website" MigrationConfiguration="Website.Migrations.Configuration, Website" />
</Object>
</ObjectGroup>
<ObjectGroup Name="Website.My.MySettings.DbConnectionString" Order="2" Enabled="False">
<Destination Path="" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=(local);Initial Catalog=Website;Integrated Security=False;Persist Security Info=False;User ID=username;Password=password" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\Website.My.MySettings.DbConnectionString_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="Data Source=(local);Initial Catalog=Website;Integrated Security=False;Persist Security Info=False;User ID=username;Password=password" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="$(DeployParameterPrefix)Website.Db.Context-Web.config Connection String" />
</ItemGroup>
<ItemGroup>
<_ConnectionStringsToInsert Include="Website.Db.Context" />
</ItemGroup>
</Project>
Unlike Azure, setting up a continuous deployment from VSTS/TFS to these priced hosting servers do not have a built-in solution.
And this is bidirectional issue, TFS also greet other platform provide their official extension as a 3-party task in Marketplace. You could submit a uservoice in their site.
As a workaround, TFS is also using MSBuild in the build agent to perform build. .publishsettings also related to Azure. If you could use Web Deploy with GoDaddy locally through Visual Studio. It' should also be able to do this in TFS.
Take a look at this tutorial, using below MSBuild Argument:
/p:DeployOnBuild=true /p:PublishProfile="sitename.com - Web Deploy.pubxml" /p:AllowUntrustedCertificate=true /p:UserName="uname" /p:Password="password" /p:VisualStudioVersion=14.0
More details please refer this tutorial: HOW TO SETUP VSTS CONTINUOUS DEPLOYMENT FOR GODADDY
But according to this discussion, seems even directly using Visual Studio Web Deploy to handle with the GoDaddy is also not so stability. If you get same issue, you may deal with their support.
It turned out that I didn't have the full VS toolset installed on the server. I'd only installed the bare minimum, as I didn't need anything more than the VSTest capability.
So I updated and installed Web and Desktop this time, and the deployment sailed right through.
Credits to Microsoft Support Services for helping me with this.

Publish of ASP.Net Core project fails with "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s)

Publish of ASP.Net Core project fails with next error:
"DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s).
They must have the same number of items.
I get an error when I try to publish an ASP.Net Core website to Azure. It builds and runs fine locally. The output prints this:
Task "Copy"
Task Parameter:
SourceFiles=
C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\appsettings.json
CopyToPublishDirectory=PreserveNewest
RelativePath=appsettings.json
TargetPath=appsettings.json
C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\appsettings.json
CopyToPublishDirectory=PreserveNewest
RelativePath=appsettings.json
TargetPath=appsettings.json
Task Parameter:DestinationFiles=C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\obj\Release\netcoreapp1.0\PublishTemp\PublishOutput\appsettings.json
Task Parameter:OverwriteReadOnlyFiles=False
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Publish.targets(100,5): Error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 2 item(s). They must have the same number of items.
Output Item(s): FileWrites=C:\Users\Mikael\Source\Repos\GoMap-Web\src\Web\obj\Release\netcoreapp1.0\PublishTemp\PublishOutput\appsettings.json
Done executing task "Copy" -- FAILED.
Done building target "_CopyResolvedFilesToPublishPreserveNewest" in project "Web.csproj" -- FAILED.
Done building project "Web.csproj" -- FAILED.
The Microsoft.NET.Publish.targets file (the relevant part, i belive) look like this:
============================================================
CopyFilesToPublishDirectory
Copy all build outputs, satellites and other necessary files to the publish directory.
============================================================
-->
<Target Name="CopyFilesToPublishDirectory"
DependsOnTargets="_CopyResolvedFilesToPublishPreserveNewest;
_CopyResolvedFilesToPublishAlways" />
<!--
============================================================
_CopyResolvedFilesToPublishPreserveNewest
Copy _ResolvedFileToPublishPreserveNewest items to the publish directory.
============================================================
-->
<Target Name="_CopyResolvedFilesToPublishPreserveNewest"
DependsOnTargets="_ComputeResolvedFilesToPublishTypes"
Inputs="#(_ResolvedFileToPublishPreserveNewest)"
Outputs="#(_ResolvedFileToPublishPreserveNewest->'$(PublishDir)%(RelativePath)')">
<!--
Not using SkipUnchangedFiles="true" because the application may want to change
one of these files and not have an incremental build replace it.
-->
<Copy SourceFiles = "#(_ResolvedFileToPublishPreserveNewest)"
DestinationFiles="#(_ResolvedFileToPublishPreserveNewest -> '$(PublishDir)%(RelativePath)')"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
<!--
============================================================
_CopyResolvedFilesToPublishAlways
Copy _ResolvedFileToPublishAlways items to the publish directory.
============================================================
-->
<Target Name="_CopyResolvedFilesToPublishAlways"
DependsOnTargets="_ComputeResolvedFilesToPublishTypes">
<!--
Not using SkipUnchangedFiles="true" because the application may want to change
one of these files and not have an incremental build replace it.
-->
<Copy SourceFiles = "#(_ResolvedFileToPublishAlways)"
DestinationFiles="#(_ResolvedFileToPublishAlways -> '$(PublishDir)%(RelativePath)')"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
I have changed the DestinationFiles="#(_ResolvedFileToPublishPreserveNewest -> '$(PublishDir)%(RelativePath)')" according to another post here but I still get the same failure, and I don't know enough about it to find any clear errors, can anyone offer some insight? If this is affected by the bug mentioned in other posts that has no workaround, what alternative ways could I try to publish the app to azure that might work better?

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

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

Transform external config in a web role

Can slowcheetah transform an external config file in an azure web role? e.g. I have logging info in log4net.config. But the transformed version does not get created when packaged.
I did not manage to get slowCheetah working in my Azure solution.
One alternative you can use is to create complete config files for each environment - e.g. :
log4net.debug.config
log4net.release.config
and copy the contents of these into the log4net.config at buildtime depending on the build configuration chosen.
This is done by adding a build target to your csproj file like so:
<Target Name="BeforeBuild">
<Delete Files="$(ProjectDir)log4net.config" />
<Copy SourceFiles="$(ProjectDir)log4net.$(Configuration).config"
DestinationFiles="$(ProjectDir)log4net.config" />
</Target>
(you may have to modify the paths in the script depending on where in the solution your config files are)
You can find more information on MSBuild and manipulating your .csproj file here and here

CruiseControl.NET post-build actions

We have CC.NET setup on our ASP.NET app. When we build the project, the ASP.NET app is pre-compiled and copied to a network share, from which a server runs the application.
The server is a bit different from development box'es, and the next server in our staging environment differs even more. The difference is specific config files and so on - so I want to exclude some files - or delete them before the pre-compiled app is copied to a network share.
My config file looks like this:
<project name="Assembly.Web.project">
<triggers>
<intervalTrigger seconds="3600" />
</triggers>
<sourcecontrol type="svn">
<trunkUrl>svn://svn-server/MyApp/Web/Trunk</trunkUrl>
<workingDirectory>C:\build-server\Assembly\Web\TEST-HL</workingDirectory>
<executable>C:\Program Files (x86)\SVN 1.5 bin\svn.exe</executable>
<username>uid</username>
<password>pwd</password>
</sourcecontrol>
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\build-server\Assembly\Web\TEST-HL</workingDirectory>
<projectFile>C:\build-server\Assembly\Web\TEST-HL\Web\Web.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
<publishers>
<buildpublisher>
<sourceDir>C:\build-server\Assembly\Web\PrecompiledWeb</sourceDir>
<publishDir>\\test-web01\Web</publishDir>
<useLabelSubDirectory>false</useLabelSubDirectory>
<alwaysPublish>false</alwaysPublish>
</buildpublisher>
</publishers>
</project>
As you can see, I use a buildPublisher to copy the pre-compiled files to the network share. What I want to do here, is either 1) delete certain files before they are copied or 2) replace those files after they have been copied.
I DO NOT want to have some app running watching specific files for change, and then after that replace the files with other ones. I want something to be either done by CC.NET, or triggered by CC.NET.
Can you launch a .bat file with CC.NET?
I use a NAnt task for all publishing, deploying, cleaning and so on.
Take a look at MSDEPLOY or Web Deployment Projects. There is a question that will provide more detail here
You have to use NAnt for those kind of stuff.
Here is the Task Reference of Nant..
Of course CruiseControl.NET can run a batch file, simply use the exec task. However, an easier answer might just be to have MSBuild do the task for you. It should be simple to add a few steps in the postcompile target.

Resources