<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Eric Parvin</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/ericparvin/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/ericparvin/feed.xml</link>
    <description>IIS, TFS, and .NET Lessons from the Field</description>
    <lastBuildDate>Fri, 14 Dec 2018 16:00:35 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>IIS-Sync Configuration Settings Only - No Web Site Content</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/iis-sync-configuration-settings-only-no-web-site-content</link>
      <pubDate>Thu, 15 Nov 2018 17:00:56 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2455</guid>
      <description><![CDATA[In the scenario where you make a modification of an IIS setting at the server level (not in the...]]></description>
      <content:encoded><![CDATA[In the scenario where you make a modification of an IIS setting at the server level (not in the website or web application) and want to synchronize the settings (no content) with other servers. It is important to understand the following script will only synchronize the settings aligned with the IIS server and not the web sites.

Web Deploy must be installed on the source and target server and this method uses the remote Web Deploy agent to authenticate and synchronize the changes.

<a href="https://msdnshared.blob.core.windows.net/media/2018/11/IIS_ServerLevel.png"><img width="300" height="141" class="alignleft size-medium wp-image-2465" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/11/IIS_ServerLevel-300x141.png" /></a>

&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;

The following script authenticates with the remote server using the credentials you are logged into the source server and will run in a trusted domain model. Add the username and password parameters to the -dest: command to indicate the remote server authentication method.

The <span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px">-disableLink:Content</span> extension prevents content from being synchronized and the settings <span style="float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;text-align: left;text-decoration: none;text-indent: 0px">-skip:xPath=//site -skip:objectName=section,absolutePath=system.applicationHost/applicationPools</span> command prevents the websites and applications from being established on the remote server. If this is skipped, the websites and application pools that do not exist on the remote server are created and the content is not copied over and the websites are empty.

msdeploy -verb:sync -source:webServer -dest:webServer,computerName=10.2.0.9 -disableLink:Content -disableLink:CertificateExtension -skip:xPath=//site -skip:objectName=section,absolutePath=system.applicationHost/applicationPools -whatif

Drop the -whatif to commit the changes to the remote server.]]></content:encoded>
    </item>
    <item>
      <title>Auto-Parameter Connection String for Web Deploy Package</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/auto-parameter-connection-string-for-web-deploy-package</link>
      <pubDate>Tue, 04 Sep 2018 17:26:02 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2435</guid>
      <description><![CDATA[Scenario:The connection string from the Visual Studio's project web.config over rides the connection...]]></description>
      <content:encoded><![CDATA[<p><strong><u>Scenario:</u></strong></p><p>The connection string from the Visual Studio's project web.config over rides the connection string set in the web deploy package parameters file upon deployment of the package. Meaning, the connection string defined in the in the web.config is connectionString="Server=ServerA and web deploy package has a parameter value of connectionString="Server=ServerB and the end result of the deployment is connectionString="Server=ServerA appears in the web.config. The ServerA is used for testing by the development team and ServerB is the production server and is the expected value as it is setup in the deployment process for the environment.</p><p>It appears the Web Deploy process auto-adds the connection strings to the deployment package and additional steps are required to prevent this from happening during the deployment as it can lead to two connection strings with the same name in the web.config file and also for the production web applications to point to the dev servers.</p><p>The resolutions are described in this <a href="https://stackoverflow.com/questions/16693500/is-autoparameterizationwebconfigconnectionstrings-option-the-only-way-to-preve">StackOverflow</a> post and the easiest method to resolve the issue is to change the name of the connection string variable in the Parameters.xml file from name="SQLServerConn" (Original value) to name="SQLServerConn-Web.config Connection String" </p><p>This does not require an update to the Visual Studio project file and is the easiest to implement. You can stop reading this blog post if this makes sense. If not, please continue and I will try to explain in as much detail as possible. </p><p>The process described below uses the following deployment methodology:<ul><li>Web Deploy package is created for deployment and parameters are defined using the Parameters.xml file in the Visual Studio project</li><li>Release Manager uses the tokenization process to replace values in the parameters.xml file with the variables to use for each environment</li><li>Batch file is run on the local IIS server using the Web Deploy command to update the website and uses the values in the SetParameters.xml file to replace the values in the Web Deploy package with the parameters specified in the Release Manager deployment for the environment.</li></ul></p><p><strong><u>Visual Studio Project Configuration:</u></strong></p><p>The Visual Studio project is called DemoWebFormsApp</p><p>Original connection string value in the Web.config file within Visual Studio:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image001.png"><img width="670" height="27" title="clip_image001" alt="clip_image001" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image001_thumb.png" border="0"/></a></p><p><font face="Courier New">&lt;connectionStrings&gt;</font></p><p><font face="Courier New">&lt;add name="SQLServerConn" connectionString="Server=SQL2016\InstanceOne;Database=Shredder;User Id=myUsername;Password=myPassword;" /&gt;</font></p><p>Added Parameters.xml file and added to Visual Studio project. </p><p>Added parameter value to the Parameters.xml file in Visual Studio with the default value of _SQLServerConn_ with the prefix and suffix of _ in order for the tokenization process to find parameter and change value upon the Release Management deployment. </p><p>The other important difference is the addition of the -Web.config Connection String value in the parameter name. This prevents the Web Deploy command from appending the default value during the deployment process.</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image002.png"><img width="618" height="45" title="clip_image002" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image002_thumb.png" border="0"/></a></p><p><font face="Courier New">&lt;parameter name="SQLServerConn-Web.config Connection String" description="doesn't matter" defaultvalue="__SQLServerConn__" tags=""&gt;</font></p><p><font face="Courier New">&nbsp;&nbsp;&nbsp; &lt;parameterentry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[@name='SQLServerConn']/@connectionString"&gt;</font></p><p><font face="Courier New">&lt;/parameterentry&gt;</font></p><p><font face="Courier New">&lt;/parameter&gt;</font></p><p><strong><u>Build Definition:</u></strong></p><p>Create the build definition and in the Visual Studio build, add the MSBuild argument <font face="Courier New">/p:DeployOnBuild=true /p:PackageLocation=$(build.artifactstagingdirectory)</font></p><p>OR</p><p><font face="Courier New">/p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Build.ArtifactStagingDirectory) /p:DeployIisAppPath="Default Web site/FarmToken" /p:DeployOnBuild=true</font> </p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image003.png"><img width="679" height="62" title="clip_image003" alt="clip_image003" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image003_thumb.png" border="0"/></a></p><p>The MSBuild argument will create the Web Deploy package and generate the Parameters file</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image004.png"><img width="244" height="138" title="clip_image004" style="margin: 0px" alt="clip_image004" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image004_thumb.png" border="0"/></a></p><p>Verify the SetParameters.xml file has the correct parameters created and values after the first build. </p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image005.png"><img width="244" height="11" title="clip_image005" style="margin: 0px" alt="clip_image005" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image005_thumb.png" border="0"/></a></p><p><strong><u>Release Management Definition:</u></strong></p><p>Download the <a href="https://marketplace.visualstudio.com/items?itemName=colinsalmcorner.colinsalmcorner-buildtasks">Colin's ALM Corner Build</a> and Release extension and enable</p><p>The release definition will have the following steps:<ul><li>Replace tokens in the SetParameters.xml file with the correct values for the environment</li><li>Copy the Web Deploy package to a location on the IIS server, like C:\Deployments\Latest</li><li>Run the Web Deploy package command to update the website files</li></ul></p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image006.png"><img width="427" height="131" title="clip_image006" alt="clip_image006" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image006_thumb.png" border="0"/></a></p><p><strong>Replace Token Task:</strong></p><p>Within the Replace Token task, select the folder in the Drop folder where the build artifacts are stored:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image007.png"><img width="318" height="226" title="clip_image007" alt="clip_image007" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image007_thumb.png" border="0"/></a></p><p>Change the search pattern to the SetParameters.xml file</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image008.png"><img width="425" height="181" title="clip_image008" alt="clip_image008" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image008_thumb.png" border="0"/></a></p><p>The Token Regex pattern is __(\w+)__ in order to find the values in the SetParameter.xml to replace</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image009.png"><img width="168" height="115" title="clip_image009" alt="clip_image009" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image009_thumb.png" border="0"/></a></p><p><strong>Copy Files Task:</strong></p><p>Set the location of the Web Deploy package on the IIS server. Can either copy to each machine in the farm. Or, copy to gold server and deploy. Test, and then use Web Deploy to copy to the other servers in the farm. This requires an additional batch file for the Web Deploy command.</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image010.png"><img width="383" height="228" title="clip_image010" alt="clip_image010" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image010_thumb.png" border="0"/></a></p><p>The target folder is a location on the IIS server where the files are to be copied</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image011.png"><img width="386" height="230" title="clip_image011" alt="clip_image011" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image011_thumb.png" border="0"/></a></p><p><strong>Batch File Script to Deploy:</strong></p><p>The batch file is created as part of the Web Deploy package creation and this task calls the command with the /Y switch to overwrite files in the web site.</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image012.png"><img width="383" height="138" title="clip_image012" alt="clip_image012" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image012_thumb.png" border="0"/></a></p><p>This is the batch file created as part of the Web Deploy package and will have the same name as the web deploy package. </p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image013.png"><img width="379" height="176" title="clip_image013" alt="clip_image013" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image013_thumb.png" border="0"/></a></p><p><strong>Add the Environment Variables:</strong></p><p>For each variable in the Parameters.xml file, add a variable to the environment. The RM tokenizer will replace the value in the Parameters.xml file with the variable value.</p><p>Use Release scoped variables in order to reuse the variables for each of the environments:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image014.png"><img width="729" height="34" title="clip_image014" alt="clip_image014" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image014_thumb.png" border="0"/></a></p><p>SQLServerConn is the name of the connection string in the web.config file and the tokenizing task will find _SQLServerConn_ in the SetParameters.xml file and replace it with the value of Server=Server02\InstanceOne;Database=Shredder;User Id=myUsername;Password=myPassword; during the Web Deploy deployment.</p><p><strong>Prepare SetParameters.xml:</strong></p><p>The DemoWebFormsApp.deploy.cmd will perform the actual web.config updates and other areas of the website at the point of the deployment of the website. The SetParameters.xml file will contain the correct values to apply to the website. </p><p>Can use the command file created by the build process, or create own file to use to update the website. </p><p>Verify the Replacements in Parameter File was successful:</p><p>Check the Replace Tokens task in the logs</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image015.png"><img width="686" height="49" title="clip_image015" alt="clip_image015" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image015_thumb.png" border="0"/></a></p><p>SetParameters.xml Final Values</p><p>The SetParameters.xml file on the IIS server will have the value from the RM variable.</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image016.png"><img width="677" height="21" title="clip_image016" alt="clip_image016" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image016_thumb.png" border="0"/></a></p><p><strong>Update Website w/Web Deploy Command:</strong></p><p>The Batch Script executes the </p><p>C:\_Agent\LatestDeployments\FarmDemo_Token\LatestPackage\DemoWebFormsApp.deploy </p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image017.png"><img width="657" height="167" title="clip_image017" alt="clip_image017" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image017_thumb.png" border="0"/></a></p><p>WebSite Web.config Value</p><p>Verify the connection string in the web.config contains the correct value:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image018.png"><img width="672" height="29" title="clip_image018" alt="clip_image018" src="https://msdnshared.blob.core.windows.net/media/2018/09/clip_image018_thumb.png" border="0"/></a></p><p>Fini!</p>]]></content:encoded>
    </item>
    <item>
      <title>Is SQL Job Required to Maintain Indexes for TFS databases</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/is-sql-job-required-to-maintain-indexes-for-tfs-databases</link>
      <pubDate>Fri, 24 Aug 2018 13:19:07 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2065</guid>
      <description><![CDATA[The recommendation from the Product Group is to not run a separate index maintenance job as the...]]></description>
      <content:encoded><![CDATA[<p>The recommendation from the Product Group is to <b><u>not</u></b> run a separate index maintenance job as the Optimize Databases TFS job will handle updating of indexes for TFS related databases (Config/Collection DBs). The stored procedure prc_OptimizeDatabase goes through all the indices (including clustered indices) and rebuilds them online if they are more than 20% fragmented. Some of the indices are blacklisted (i.e. not rebuilt) – you can find these in tbl_ReindexExclusions. </p><p>From the comments in the prc_OptimizeDatabase stored procedure, it appears the tbl_content table is skipped in this job and it is the only entry in the tbl_ReindexExclusions table.</p><p>-- First we defragment all existing indices</p><p>-- Iterate through all tables and call ALTER INDEX</p><p>-- Exclude tbl_Content as it gets to be really large and does not need re-organization</p><p>This <a href="https://blogs.msdn.microsoft.com/granth/2013/10/07/what-does-a-well-maintained-team-foundation-server-look-like/">article</a> explains some basic SQL admin tasks there is nothing different for TFS databases compared to other transactional databases. </p>]]></content:encoded>
    </item>
    <item>
      <title>ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER Deploying w/TFS</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/error_insufficient_access_to_site_folder-deploying-wtfs</link>
      <pubDate>Thu, 26 Jul 2018 18:24:09 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2055</guid>
      <description><![CDATA[Scenario:The TFS deploy Agent is setup to use built in account Network Service as the identity to...]]></description>
      <content:encoded><![CDATA[<p><br /></p><p><strong><u>Scenario:</u></strong></p><p>The TFS deploy Agent is setup to use built in account Network Service as the identity to conduct actions on server. Using Web Deploy to update the web site using a batch file and Web Deploy package to update a website folder. </p><p><strong><u>Error Encountered:</u></strong></p><p>Upon execution of the batch file, the following error occurs:</p><p>2018-05-09T00:24:30.2375370Z Info: Adding directory (Default Web Site/BIO_POC\bin).</p><p>2018-05-09T00:24:30.2531618Z Error Code: ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER</p><p>2018-05-09T00:24:30.2531618Z More Information: Unable to perform the operation ("Create Directory") for the specified directory ("C:\inetpub\wwwroot\BIO_POC\bin"). This can occur if the server administrator has not authorized this operation for the user credentials you are using. Learn more at: <a href="https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER">https://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER</a>.</p><p><strong><u>Problem:</u></strong></p><p>The TFS build/deploy agent is using the credential of the server's built-in Network Service account and the agent is setup to run as a server. The Network Service account did not have Full control permissions on the folder where the website is located to add/delete files and folders as needed.</p><p></p><p><strong><u>Resolution:</u></strong></p><p>One of the following</p><ol><li>Change the identity of the account the agent is using to a local account with membership in the Local Admin group on the server</li><li>Change the identity of the account the agent is using to a Domain account with membership in the Local Admin group on the server</li><li>Add the NT AUTHORITY\NETWORK SERVICE account to the C:\Inetpub\wwwroot\DefaultWebSite\&lt;site&gt; folder with FULL PERMISSIONS </li></ol>]]></content:encoded>
    </item>
    <item>
      <title>Load Balancing TFS Code Search Servers</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/load-balancing-tfs-code-search-servers</link>
      <pubDate>Thu, 21 Jun 2018 11:22:48 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2045</guid>
      <description><![CDATA[At this time, it is NOT possible to load balance the TFS Code Search servers (Elasticsearch) as the...]]></description>
      <content:encoded><![CDATA[<p>At this time, it is <strong><u>NOT</u></strong> possible to load balance the TFS Code Search servers (Elasticsearch) as the service is not designed for load balancing. TFS supports a single Code Search server in the TFS environment. </p><p>The Code Search service is considered an ancillary service to TFS and would not impact the developers ability to complete source control check-in/out and other actions to deliver code if the server hosting the server were to go offline.</p><p>Here are instructions on how to setup multiple Application Tiers (AT) and configuring Code Search with multiple ATs in the TFS environment:</p><p><a href="https://docs.microsoft.com/en-us/tfs/server/install/multiple-server">https://docs.microsoft.com/en-us/tfs/server/install/multiple-server</a></p><p><a href="https://blogs.msdn.microsoft.com/tapas_sahoos_blog/2017/09/28/configuring-search-for-tfs-in-a-multi-application-tier-setup/">https://blogs.msdn.microsoft.com/tapas_sahoos_blog/2017/09/28/configuring-search-for-tfs-in-a-multi-application-tier-setup/</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Issue with Accessing IIS Redirection.config file during Deployment</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/issue-with-accessing-iis-redirection-config-file-during-deployment</link>
      <pubDate>Mon, 11 Jun 2018 14:27:01 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2035</guid>
      <description><![CDATA[Scenario:The TFS build/release agent is configured to use the built in account Network Service (or a...]]></description>
      <content:encoded><![CDATA[<p><strong>Scenario:</strong></p><p>The TFS build/release agent is configured to use the built in account Network Service (or a domain account that is not a member of the local admin group) when running as service. A file permission error occurs when the release is attempting to update files in the IIS for the website using Web Deploy and the TFS agent is configured as a service to run under the security context of Network Service. </p><p>This example uses the following syntax for the update:</p><p>msdeploy -verb:sync -source:Package=C:\_Agent\LatestDeployments\FarmDemo\LatestPackage\DemoWebFormsApp.zip -dest:Auto</p><p><strong><u>Problem Encountered:</u></strong></p><p>Upon execution of the batch file, the following error occurs:<ul><li>Skipping backup because it failed due to the following error 'System.UnauthorizedAccessException: Filename: redirection.config</li><li>Error: Cannot read configuration file due to insufficient permissions</li><li>Info: Adding sitemanifest (sitemanifest).</li><li>Info: Creating application (Default Web site/FarmDemo)</li><li>Error: An error occurred when reading the IIS Configuration File 'MACHINE/REDIRECTION'. The identity performing the operation was 'NT AUTHORITY\NETWORK SERVICE'.</li><li>Error: Filename: <a href="/Windows/system32/inetsrv/config/redirection.config">\\?\C:\Windows\system32\inetsrv\config\redirection.config</a></li><li>Error: Cannot read configuration file due to insufficient permissions</li></ul></p><p><strong><u>Resolution:</u></strong></p><p>The account conducting the deployment lacks read permissions on the redirection file:<ol><li>Change the identity of the account the agent is using to a local account with membership in the Local Admin group on the server</li><li>Change the identity of the account the agent is using to a Domain account with membership in the Local Admin group on the server</li><li>Add the NT AUTHORITY\NETWORK SERVICE account to the Windows\System32\Inetsrv\Config directory with Read and List folder contents permissions</li></ol></p>]]></content:encoded>
    </item>
    <item>
      <title>MSBuild Syntax for Creating Web Deploy Packages and _Publishedwebsite folder for TFS Builds</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/msbuild-syntax-for-creating-web-deploy-packages-and-_publishedwebsite-folder-for-tfs-builds</link>
      <pubDate>Fri, 01 Jun 2018 09:43:12 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=2025</guid>
      <description><![CDATA[_PublishedWebsite folderJust the _PublishedWebsite...]]></description>
      <content:encoded><![CDATA[<p><br /></p><p><font size="3"><strong><u>_PublishedWebsite folder</u></strong></font></p><p><strong>Just the _PublishedWebsite folder:</strong></p><p><font face="Courier New" size="3">/p:outdir=$(Build.ArtifactStagingDirectory)</font></p><p>Creates a Published Site within the drop location for the build: </p><p><font face="Courier New" size="3">/p:outdir=$(Build.ArtifactStagingDirectory)\drop</font></p><p>Or use the Publish Artifact task to copy the contents of the package just created and upload to the drop zone:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0011.png"><img width="330" height="106" title="clip_image001" alt="clip_image001" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image001_thumb1.png" border="0"/></a></p><p><strong><u><font size="3">Web Deploy Package:</font></u></strong></p><p><strong>Create Just the Web Deploy Package:</strong></p><p><font face="Courier New" size="3">/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Build.ArtifactStagingDirectory</font>)</p><p><strong>Transform Web.config and create Web Deploy Package </strong></p><p><font face="Courier New" size="3">/p:DeployOnBuild=True /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PublishProfile=$(DeploymentConfiguration) /p:TransformConfigFile=true</font></p><p>On Variables tab page DeploymentConfiguration has to be configured. It must be the Name of the publish Profile (filename of the pubxml file). If the file Name is Build.pubxml the publish profile is Build. <a href="https://stackoverflow.com/questions/35351695/build-and-deploy-a-web-application-with-tfs-2015-build">More</a> Details.</p><p><strong><u><font size="3">Create Both Published Web Site and Web Deploy Package using MSBuild:</font></u></strong>&nbsp;</p><p><font face="Courier New" size="3">/p:OutDir=$(Build.ArtifactStagingDirectory) /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true</font> </p><p>This will create the published website folder with the main site and the Web Deploy package:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0021.png"><img width="244" height="153" title="clip_image002" style="margin: 0px" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image002_thumb1.png" border="0"/></a></p><p><strong><u>Web.config Transform</u></strong></p><p><font face="Courier New" size="3">/p:OutDir=$(Build.ArtifactStagingDirectory) /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false</font></p><p>The /p:DeployOnBuild=true parameter will ensure the Web.config transform is completed</p>]]></content:encoded>
    </item>
    <item>
      <title>Releasing to Multiple Environments with Web Deploy and Parameters file Tokenization</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/releasing-to-multiple-environments-with-web-deploy-and-parameters-file-tokenization</link>
      <pubDate>Fri, 01 Jun 2018 09:39:30 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=1975</guid>
      <description><![CDATA[Build and Release Scenario:

This method uses a combination of the Web Deploy Parameters and the...]]></description>
      <content:encoded><![CDATA[<strong>Build and Release Scenario:</strong>

This method uses a combination of the Web Deploy Parameters and the Tokenization task in Release Management to transform the parameters at the time of release in each environment. The web.config values are changed when the deployment occurs into the environment through the use of variables set in RM for the deployment environment. Follows the model explained in Colin's <a href="https://colinsalmcorner.com/post/end-to-end-walkthrough-deploying-web-applications-using-team-build-and-release-management">blog</a> post and uses his extension to transforms the key values.

This method differs from the web.config transform method as it uses the Web Deploy parameters file within the VS project to define the parameters and creates the Web Deploy parameters file to use for the changing of the web.config values during the deployment. This allows for the creation of a single build artifact and the movement of build through the release pipeline and changing of the web.config values as it moves to each environment.

<strong><span style="font-size: medium"><u>Visual Studio Project Requirements:</u></span></strong>

Add appSettings keys to Project:

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/image2.png"><img width="244" height="80" title="image" style="margin: 0px" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/06/image_thumb1.png" border="0" /></a>

<strong>Parameters File in Visual Studio:</strong>

This method requires a Parameters.xml file is added to the root of the Visual Studio project. This is a requirement to hold the parameters to tokenize.

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image001.png"><img width="153" height="72" title="clip_image001" style="margin: 0px" alt="clip_image001" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image001_thumb.png" border="0" /></a>

Here are example parameters to start a new file:

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/image3.png"><img width="794" height="268" title="image" alt="image" src="https://msdnshared.blob.core.windows.net/media/2018/06/image_thumb2.png" border="0" /></a>

Add the parameters to the file and ensure the default value is set to "__parameter__" for the tokenization process to complete. The second most important piece is the path to the key in the web.config file with the match property as shown above.

The modification to the Visual Studio project is completed and there are no other changes. Check changes into TFS.

<strong><u><span style="font-size: medium">TFS Build Definition:</span></u></strong>

Create the build definition and in the Visual Studio build, add the following MSBuild arguments:

<span style="font-family: Courier New">/p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(Build.ArtifactStagingDirectory) /p:DeployOnBuild=true /p:DeployIisAppPath="Default Web site/FarmToken"</span>

The optional parameter DeployIISAppPath allows for the name of the IIS web application to be changed on deployment.  <span style="font-family: Courier New">/p:DeployIisAppPath="Default Web site/FarmToken"</span>

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image002.png"><img width="852" height="79" title="clip_image002" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image002_thumb.png" border="0" /></a>

The MSBuild process creates the Web Deploy package and generate the Parameters file, which is config.SetParameters.xml

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image003.png"><img width="244" height="166" title="clip_image003" style="margin: 0px" alt="clip_image003" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image003_thumb.png" border="0" /></a>

During the execution of the build process, the values in the Parameters.xml file are placed in the Config.SetParameters.xml file and this is used for the tokenization process on the release.

For instance, the Environment key value in the web.config has the value of Dev. The default value is obtained from the Parameters.xml file during the build and placed in the Config.SetParameters.xml file.

Verify the SetParameters.xml file has the correct parameters created and values

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image004.png"><img width="738" height="102" title="clip_image004" alt="clip_image004" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image004_thumb.png" border="0" /></a>

<strong><u><span style="font-size: medium">Release Management Definition:</span></u></strong>

Download the <a href="https://marketplace.visualstudio.com/items?itemName=colinsalmcorner.colinsalmcorner-buildtasks">Colin's ALM Corner Build</a> and Release extension and enable

The release definition will have the following steps:
<ul>
 	<li>Replace tokens in the SetParameters.xml file with the correct values for the environment</li>
 	<li>Copy the Web Deploy package to a location on the IIS server, like C:\Deployments\Latest</li>
 	<li>Run the Web Deploy package command to update the website files</li>
</ul>
<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0014.png"><img width="437" height="134" title="clip_image001[4]" alt="clip_image001[4]" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0014_thumb.png" border="0" /></a>

<strong>Replace Token Task:</strong>

Select the folder in the Drop folder where the build artifacts are stored:

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0025.png"><img width="367" height="196" title="clip_image002[5]" alt="clip_image002[5]" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0025_thumb.png" border="0" /></a>

Change the search pattern to the SetParameters.xml file

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0034.png"><img width="486" height="206" title="clip_image003[4]" alt="clip_image003[4]" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0034_thumb.png" border="0" /></a>

<cite></cite>

Keep all other defaults.

<strong>Copy Files Task:</strong>

Set the location of the Web Deploy package on the IIS server. Can either copy to each machine in the farm. Or, copy to gold server and deploy. Test, and then use Web Deploy to copy to the other servers in the farm. This requires an additional batch file for the Web Deploy command.

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0046.png"><img width="505" height="187" title="clip_image004[6]" alt="clip_image004[6]" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0046_thumb.png" border="0" /></a>

<strong>Batch File Script to Deploy:</strong>

This script is part of the Web Deploy package and calling the /Y switch to overwrite files in the web site.

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image005.png"><img width="518" height="104" title="clip_image005" alt="clip_image005" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image005_thumb.png" border="0" /></a>

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image006.png"><img width="211" height="134" title="clip_image006" style="margin: 0px" alt="clip_image006" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image006_thumb.png" border="0" /></a>

<strong>Add the Environment Variables:</strong>

For each variable in the Parameters.xml file, add a variable to the environment. The RM tokenizer will replace the value in the Parameters.xml file with the variable value.

Use Release scoped variables in order to reuse the variables for each of the environments:

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image007.png"><img width="584" height="82" title="clip_image007" alt="clip_image007" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image007_thumb.png" border="0" /></a>

Can add a Variable Group to each environment

<strong>Prepare SetParameters.xml</strong>

The Config.deploy.cmd will perform the actual web.config updates and other areas of the website at the point of the deployment of the website. The SetParameters.xml file will contain the correct values to apply to the website.

Can use the command file created by the build process, or create own file to use to update the website.

Verify the Replacements in Parameter File was successful:

Check the Replace Tokens task in the logs

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image008.png"><img width="608" height="45" title="clip_image008" alt="clip_image008" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image008_thumb.png" border="0" /></a>

<strong>SetParameters.xml Final Values</strong>

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image009.png"><img width="541" height="132" title="clip_image009" alt="clip_image009" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image009_thumb.png" border="0" /></a>

<strong>Update Website w/Web Deploy Command</strong>

The Batch Script executes the

<span style="font-family: Courier New">C:\_Agent\LatestDeployments\FarmDemo_Token\LatestPackage\DemoWebFormsApp.deploy</span>

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image010.png"><img width="556" height="142" title="clip_image010" alt="clip_image010" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image010_thumb.png" border="0" /></a>

<strong>Set Destination IIS Web Application:</strong>

If the web application name can be specified at the time publishing through Web Deploy or set as a parameter in the SetParameters.xml file in the MSBuild arguments at the time the build package is created.]]></content:encoded>
    </item>
    <item>
      <title>Install and Configure Web Deploy on IIS</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/install-and-configure-web-deploy-on-iis</link>
      <pubDate>Thu, 31 May 2018 20:40:28 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=1645</guid>
      <description><![CDATA[Purpose:Describes steps to setup an IIS website publish method between servers. This method will...]]></description>
      <content:encoded><![CDATA[<p><br /></p><p><strong>Purpose:</strong></p><p>Describes steps to setup an IIS website publish method between servers. This method will push web files from the source server to the destination server at the website level. </p><p><strong>Install and Configure Web Deploy Service:</strong></p><p>Download version 3.6 <a href="https://www.microsoft.com/en-us/download/details.aspx?id=43717">https://www.microsoft.com/en-us/download/details.aspx?id=43717</a></p><p>Install on IIS server using Admin level credentials</p><p>Select the Change option to adjust the services being installed and make sure the remote agent is installed</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image00114.png"><img width="420" height="221" title="clip_image001" alt="clip_image001" src="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image001_thumb12.png" border="0"/></a></p><p><cite></cite></p><p>Verify the Web Deployment Agent service is installed and the service is to Auto start:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image00223.png"><img width="420" height="40" title="clip_image002" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image002_thumb11.png" border="0"/></a></p><p><strong>Set System Environment Variable:</strong></p><p>On the server, or workstation, where the Web Deploy commands are to be executed, add the path to the MSDeploy.exe to the System Path variable in order to call MSDeploy.exe without a fully qualified path.</p><p>Windows Key + X -&gt; System -&gt; Advanced System Settings -&gt; Environment Variables -&gt; Path</p><p>Add the path C:\Program Files\IIS\Microsoft Web Deploy V3</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image0039.png"><img width="559" height="298" title="clip_image003" alt="clip_image003" src="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image003_thumb4.png" border="0"/></a></p><p><strong>How the Web Deploy Service Works:</strong></p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image00410.png"><img width="553" height="192" title="clip_image004" alt="clip_image004" src="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image004_thumb9.png" border="0"/></a></p><p>This method will use the top path to allow only Admins to publish from the source web server to the destination, or target server using the Web Deploy service running on the destination server. The service must be set to auto-start and running to ensure the deployment is successful. </p><p><strong>Setup Source IIS Server:</strong></p><p>This server maybe part of the release pipeline as the staging, or prod IIS server and hosts the website files to move into the production environment. </p><p>Setup the website with the name, bindings, and path to application files comprising the website. </p><p>Test website to ensure it is fully functional.</p><p><strong>Test the Sync Source to Target:</strong></p><p>Verify the Web Deploy service is functional on the target, or destination server, by issuing the following commands from the command line:</p><p>msdeploy -verb:sync -source:apphostconfig="FabrikamDev" -dest:apphostconfig="FabrikamDev",computername=10.0.0.2 -whatif -verbose</p><p>The -source and -destination websites must be changed to match your environment as well the name, or IP of the remote server.</p><p>Here is a breakout of the syntax for Web Deploy:</p><p><a href="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image0051.png"><img width="785" height="408" title="clip_image005" alt="clip_image005" src="https://msdnshared.blob.core.windows.net/media/2018/05/clip_image005_thumb1.png" border="0"/></a></p><p><strong>Setup Script to Publish:</strong></p><p>The method to perform the actual publish action is by removing the -verbose command and this will commit the changes to the remote IIS server.</p><p>msdeploy -verb:sync -source:apphostconfig="FabrikamDev" -dest:apphostconfig="FabrikamDev",computername=10.0.0.2 </p><p><strong>Troubleshooting Web Deploy and other Resources:</strong></p><p>Blog on different options with Web Deploy: <a href="https://blogs.msdn.microsoft.com/ericparvin/tag/web-deploy/">https://blogs.msdn.microsoft.com/ericparvin/tag/web-deploy/</a></p><p>Errors publishing from Visual Studio and Console: <a href="https://www.iis.net/learn/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio">https://www.iis.net/learn/publish/troubleshooting-web-deploy/troubleshooting-web-deploy-problems-with-visual-studio</a></p><p>Troubleshooting Common Errors: <a href="https://www.iis.net/learn/publish/troubleshooting-web-deploy/troubleshooting-common-problems-with-web-deploy">https://www.iis.net/learn/publish/troubleshooting-web-deploy/troubleshooting-common-problems-with-web-deploy</a></p><p>Web Deploy Error Codes: <a href="https://www.iis.net/learn/publish/troubleshooting-web-deploy/web-deploy-error-codes">https://www.iis.net/learn/publish/troubleshooting-web-deploy/web-deploy-error-codes</a></p><p><strong>Log File Location:</strong></p><p>C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp\MSDepSvc.log</p>]]></content:encoded>
    </item>
    <item>
      <title>MSDeploy Not Found using Release Management Task</title>
      <link>https://docs.microsoft.com/archive/blogs/ericparvin/msdeploy-not-found-using-release-management-task</link>
      <pubDate>Wed, 09 May 2018 13:48:34 GMT</pubDate>
      <dc:creator><![CDATA[Eric Parvin]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ericparvin/?p=1475</guid>
      <description><![CDATA[Scenario:Setup TFS Agent to use built in account Network Service as the identity to conduct actions...]]></description>
      <content:encoded><![CDATA[<p><strong>Scenario:</strong></p><p>Setup TFS Agent to use built in account Network Service as the identity to conduct actions on server. Using Web Deploy to update the web site using a batch file and Web Deploy package with the following syntax:</p><p>msdeploy -verb:sync -source:Package=C:\_Agent\LatestDeployments\FarmDemo\LatestPackage\DemoWebFormsApp.zip -dest:Auto -disableLink:AppPoolExtension</p><p><strong>Error Encountered:</strong></p><p>2018-04-24T22:09:42.6711726Z 'msdeploy' is not recognized as an internal or external command,</p><p>2018-04-24T22:09:42.6711726Z operable program or batch file.</p><p>2018-04-24T22:09:42.6711726Z c:\_Agents\Agent_1\_work\r1\a&gt;msdeploy -verb:sync -source:contentPath=C:\_Deployments\OnlineServices\LatestDeploy -dest:contentPath="Default Web Site/OnlineServices" </p><p>2018-04-24T22:09:43.6711838Z ##[error]Process completed with exit code 1.</p><p>2018-04-24T22:09:43.6711838Z ##[section]Finishing: Run script C:\_Deployments\OnlineServices\OnlineServices_Update.cmd</p><p><strong>Problem:</strong></p><p>The path to MSDeploy was set after the build agent was installed and the Path variable was cached with the location of MSDeploy not in the path.</p><p><strong>Resolution:</strong></p><p>Restart the build agent service and the new path variable is picked up.</p>]]></content:encoded>
    </item>
  </channel>
</rss>