<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blog.magenic.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Fuzzy's Blogic</title><subtitle type="html">Dan Sniderman's musings on Technology</subtitle><id>http://blog.magenic.com/blogs/daniels/atom.aspx</id><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blog.magenic.com/blogs/daniels/atom.aspx" /><generator uri="http://communityserver.org" version="2.1.60809.935">Community Server</generator><updated>2008-02-07T17:52:00Z</updated><entry><title>Deploying SSRS Reports from Powershell</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/11/25/Deploying-SSRS-Reports-from-Powershell.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/11/25/Deploying-SSRS-Reports-from-Powershell.aspx</id><published>2008-11-25T22:17:00Z</published><updated>2008-11-25T22:17:00Z</updated><content type="html">&lt;p&gt;My current client has a BI group that writes SSRS reports.&amp;nbsp; In the &amp;quot;legacy&amp;quot; ALM tool they built, they used VSS, nAnt,Cruise Control and a product called &amp;quot;Visual Intercept&amp;quot; to &amp;quot;build&amp;quot; (actually just extract RDL files) and a nAnt script with a custom task to Deploy the SSRS report (RDL File) to Reporting Services.&lt;/p&gt;&lt;p&gt;We migrated to TFS and use a lot of Powrshell for the deploy scripts.&amp;nbsp; I searched for some solutions from Powershell to deploy RDL&amp;#39;s that I felt was a good fit.&amp;nbsp; This solution: &lt;a href="http://blogs.devhorizon.com/reza/?p=751"&gt;http://blogs.devhorizon.com/reza/?p=751&lt;/a&gt;&amp;nbsp;is for a Sharepoint Reporting Service Integration.&amp;nbsp; These are stand-alone SSRS reports - so I&amp;#39;m not even sure if I have the .DLL it relies on &amp;quot;ReportService2006.dl&amp;quot; so it was no go.&lt;/p&gt;&lt;p&gt;The other solution that looks quite promising, from Paul Stovell at Readify &lt;a href="http://www.paulstovell.com/blog/reporting-services-automation"&gt;http://www.paulstovell.com/blog/reporting-services-automation&lt;/a&gt;&amp;nbsp;is an excellent approach, but relies on a utility &amp;quot;rs.exe&amp;quot;.&amp;nbsp; But that wasn&amp;#39;t installed on the server they run the deploys from (actually the TFS Build server for the time being) and I didn&amp;#39;t want any dependencies I didn&amp;#39;t have complete control over.&lt;/p&gt;&lt;p&gt;Being a C# guy - I figured the easiest thing was just to write copy the code from the original nAnt custom Task that called the SSRS Web Service to Deploy the report.&amp;nbsp; I wrote a very simple Wrapper to the webservice as a Static Method to a Static Class.&amp;nbsp; I then just copy the generated DLL&amp;#39;s to the Build/Deploy server - and call that wrapper from the Deploy script.&amp;nbsp; Simple enough.&lt;/p&gt;&lt;p&gt;I cleaned the original code a bit - adding an integer return that shows 0 for success, 4 for warnings and either 12 or 16 for a fatal error.&amp;nbsp; The C# Code is here.&amp;nbsp; I just added a .NET 2.0 style WebService Reference (as Derick Whitaker explains here: &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/07/21/referencing-2-0-web-services-asmx-in-visual-studio-2008.aspx"&gt;http://devlicio.us/blogs/derik_whittaker/archive/2008/07/21/referencing-2-0-web-services-asmx-in-visual-studio-2008.aspx&lt;/a&gt;&amp;nbsp;&amp;nbsp;in case you don&amp;#39;t know how) to &lt;a href="http://localhost/reportserver/reportservice.asmx?wsdl"&gt;http://localhost/reportserver/reportservice.asmx?wsdl&lt;/a&gt;&amp;nbsp;(don&amp;#39;t use ReportService2005.asmx - that&amp;#39;s a different web service!)&lt;/p&gt;&lt;p&gt;C#&lt;/p&gt;&lt;p&gt;using System;&lt;br /&gt;using System.Collections.Generic;&lt;br /&gt;using System.IO;&lt;br /&gt;using System.Xml;&lt;br /&gt;using System.Linq;&lt;br /&gt;using System.Text;&lt;br /&gt;using SSRSDeployer.ReportServer;&lt;br /&gt;using System.Web.Services.Protocols;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;namespace SSRSDeployer&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static class SSRSDeployer&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static int Deploy(string webServiceURL, string rdlPath, string parentFolder, string reportName, out string warnings)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create an instance of the WebService Proxy and set URL and credentials&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ReportingService rs = new ReportingService();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rs.Url = webServiceURL;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rs.Credentials = System.Net.CredentialCache.DefaultCredentials;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Byte[] definition = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Warning[] warns = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StringBuilder sb = new StringBuilder();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int ret = 0;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //read the file as a filestream into a byte array&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileStream stream = File.OpenRead(rdlPath);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; definition = new Byte[stream.Length];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stream.Read(definition, 0, (int)stream.Length);&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp;&amp;nbsp;&amp;nbsp; Call the web service to create the report&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rs.Timeout = 1000000;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; warns = rs.CreateReport(reportName, parentFolder, true, definition, null);&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (warns != null)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (Warning warning in warns)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //ignore the warning about shared data source&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!(warning.Message.StartsWith(&amp;quot;The data set &amp;lsquo;&amp;quot;) &amp;amp;&amp;amp; warning.Message.Contains(&amp;quot;&amp;rsquo; refers to the shared data source &amp;lsquo;&amp;quot;) &amp;amp;&amp;amp; warning.Message.EndsWith(&amp;quot;which is not published on the report server.&amp;quot;)))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // otherwise return it to output&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(string.Format(&amp;quot;Warning returned from WebService: {0}&amp;quot;, warning.Message));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = 4;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (IOException)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //report any IO error reading the RDL file&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(string.Format(&amp;quot;Error: IOExcption reading file: {0}&amp;quot;, rdlPath));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = 12;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch (SoapException e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //report any Errors from the WebService call&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(e.Message);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret = 16;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; warnings = sb.ToString();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ret;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;To Call it from Powershell, simply load the assembly and call the Method: This Powershell script will deploy all RDL&amp;#39;s found in the specified folder with a report name matching the file name.&amp;nbsp; Make sure you put all the generated DLL&amp;#39;s from the compile to the folder referenced by the $lib= statement&lt;/p&gt;&lt;p&gt;[string] $webServiceURL = &amp;quot;&lt;a href="http://ssrsserver/ReportServer/ReportService.asmx"&gt;http://SSRSServer/ReportServer/ReportService.asmx&lt;/a&gt;&amp;quot;&lt;br /&gt;[string] $rdlPath = &amp;quot;C:\File13&amp;quot;&lt;br /&gt;[string] $parentFolder = &amp;quot;/SSRS.Folder&amp;quot;;&lt;/p&gt;&lt;p&gt;$file = Get-Item $rdlPath&lt;br /&gt;$lib=&amp;quot;C:\File13\SSRSDeployer\SSRSDeployer.dll&amp;quot;&lt;br /&gt;$x=[Reflection.Assembly]::LoadFrom($lib)&lt;/p&gt;&lt;p&gt;$files = Get-ChildItem $rdlPath *.rdl&lt;br /&gt;ForEach ($file in $files) {&lt;br /&gt;&amp;nbsp;[string] $reportName = ([string] $file.Name.ToUpper()).Replace(&amp;quot;.RDL&amp;quot;,&amp;quot;&amp;quot;)&lt;br /&gt;&amp;nbsp;[string] $warnings = &amp;quot;&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;quot;Deploying Report: $reportName&amp;quot;&lt;br /&gt;&amp;nbsp;[Int32] $result = [SSRSDeployer.SSRSDeployer]::Deploy($webServiceURL, $file.FullName, $parentFolder, $reportName, [ref] $warnings)&lt;br /&gt;&amp;nbsp;if ($result -eq 0) {&amp;quot;Deployed without Errors&amp;quot;}&lt;br /&gt;&amp;nbsp;elseif ($result -eq 4) {&amp;quot;Warnings from Deploy: $warnings&amp;quot;}&lt;br /&gt;&amp;nbsp;elseif ($result -eq 12) {&amp;quot;IO Error reading RDL File&amp;quot;}&lt;br /&gt;&amp;nbsp;elseif ($result -eq 16) {&amp;quot;Error Deploying Report: $warnings&amp;quot;}&lt;br /&gt;&amp;nbsp;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=7433" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author><category term="Powershell" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/Powershell/default.aspx" /><category term="SSRS" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/SSRS/default.aspx" /></entry><entry><title>Feeling Like Homer and exclaiming &quot;D'Oh!&quot;</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/11/24/Feeling-Like-Homer-and-exclaiming-_2200_D_2700_Oh_21002200_.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/11/24/Feeling-Like-Homer-and-exclaiming-_2200_D_2700_Oh_21002200_.aspx</id><published>2008-11-24T17:49:00Z</published><updated>2008-11-24T17:49:00Z</updated><content type="html">&lt;p&gt;I&amp;#39;m a big Simpsons fan - and one of the appeals is watching Homer do something really stupid that he should have known better and exclaim &amp;quot;D&amp;#39;oh&amp;quot; when the inevitable happens.&amp;nbsp; So there&amp;#39;s nothing more painful when you end up &amp;quot;pulling a Homer&amp;quot;...&amp;nbsp; &lt;/p&gt;&lt;p&gt;I had one today.&amp;nbsp; I was trying to solve a problem, and made it worse by doing something that I should have known better.&amp;nbsp; At my client I&amp;#39;m doing some pretty complex TFS build automation.&amp;nbsp; Since some of what I&amp;#39;m doing is pushing the limits of what I personally think should be done using MSBuild, I wrote a C# custom MSBuild task that calls PowerShell.&amp;nbsp; My complex scripting therefor is done in what I believe is by far the best scripting language on the Windows platform, instead of a tool that is excellent for determining dependencies between source code...&lt;/p&gt;&lt;p&gt;While trying to debug a problem of getting my PowerShell script in an MSBuild script, all of sudden things that were previously working started breaking.&amp;nbsp; After annoying &amp;quot;cubical neighbors with exclamations of frustration&amp;quot; - I realized what I had just done to make things worse.&lt;/p&gt;&lt;p&gt;I was deploying changes to the build server using a &amp;quot;C$&amp;quot; type file share (I have admin access to the &amp;quot;box&amp;quot;) and notepad.&amp;nbsp; I had the &amp;quot;Format-Word wrap&amp;quot; option in notepad checked - and it was inserting line breaks &amp;quot;randomly&amp;quot; in the scripts - wreaking havoc in both PowerShell and MSBuild...&lt;/p&gt;&lt;p&gt;&amp;nbsp;D&amp;#39;oh!&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=7418" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>Removing VSS Bindings to Migrate SSRS 2005 Solutions to TFS Using Powershell</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/11/18/Removing-VSS-Bindings-to-Migrate-SSRS-2005-Solutions-to-TFS-Using-Powershell.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/11/18/Removing-VSS-Bindings-to-Migrate-SSRS-2005-Solutions-to-TFS-Using-Powershell.aspx</id><published>2008-11-18T22:35:00Z</published><updated>2008-11-18T22:35:00Z</updated><content type="html">&lt;p&gt;The last task I have for a VSS to TFS Migration is to convert a large number of SSRS (SQL Server Reporting Services) Projects.&amp;nbsp; While Microsoft has a tool to migrate from VSS to TFS - I&amp;#39;ve avoided using it.&amp;nbsp; Most &amp;quot;experts&amp;quot; have advised against it for a number of reasons.&amp;nbsp; Particularly, a desire to do some refactoring on the organization of the project folders, and just to give a &amp;quot;clean start&amp;quot; for TFS.&lt;/p&gt;&lt;p&gt;For this clients other applications, generally there are a reasonable number of solutions, so manual efforts, like un-binding from VSS and re-binding to TFS in Visual Studio has not been that big of a deal.&amp;nbsp; Unfortunately my client has close to 100 SSRS projects and about half as many solutions.&amp;nbsp;&amp;nbsp; One of the Power Tools &amp;quot;tfpt.exe&amp;quot; supposedly automated re-binding to TFS - but it didn&amp;#39;t work for me.&amp;nbsp; I think it may only be intended to use in conjunction with the VSSConverter tool.&lt;/p&gt;&lt;p&gt;Another promising tool was suggested to me by fellow Magenicon-TFS-Expert &lt;font color="#810081"&gt;&lt;a href="http://blog.donnfelker.com/"&gt;Donn Felker&lt;/a&gt;.&amp;nbsp; &lt;/font&gt;&lt;font color="#000000"&gt;&lt;a href="http://codebetter.com/blogs/darrell.norton/attachment/178319.ashx" target="_blank"&gt;This tool&lt;/a&gt; &lt;/font&gt;claims to remove the binding, but it nuked the entire .sln file for me - and I don&amp;#39;t know if it fixed the .rptproj (I got too frustrated to pursue it further) Donn mentioned having similar problems, but somehow got a workaround.&amp;nbsp; I never figured it out and punted.&lt;/p&gt;&lt;p&gt;I decided to write my own PowerShell script to do it.&amp;nbsp; My approach is to do a &amp;quot;Get-Latest&amp;quot; from VSS to it&amp;#39;s working directory, then copy the files to the Workspace mapped Directory for TFS.&amp;nbsp; Then run the script, then add the files to TFS.&amp;nbsp; Here&amp;#39;s what the script does:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Clear the Read-Only flag on all the files&lt;/li&gt;&lt;li&gt;Delete the files I don&amp;#39;t want in TFS (*.suo, *.user, *.*scc)&lt;/li&gt;&lt;li&gt;Remove the binding section from the sln files&lt;/li&gt;&lt;li&gt;Remove the &amp;quot;State&amp;quot; from the .rptproj files&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The last one was the most interesting discovery.&amp;nbsp; SSRS Project Files are not MSBuild projects (like most other Visual Studio projects) but they are XML documents.&amp;nbsp; They have a &amp;quot;State&amp;quot; element that has SOMETHING encoded.&amp;nbsp; I&amp;#39;ve seen many references for SSRS issues that offer solution to &amp;quot;manually edit the .RPTProj and remove the &amp;quot;State&amp;quot; element.&amp;nbsp; So I knew it was okay to delete them.&amp;nbsp; I also discovered that through trial-and-error that this was necessary to remove the binding to VSS for the individual reports in each solution.&lt;/p&gt;&lt;p&gt;After the end of the post I have my PowerShell script that accomplishes it.&amp;nbsp; It&amp;#39;s not very fancy - without error detection etc - since this is a &amp;quot;One Shot&amp;quot; type thing - but it does what is needed.&amp;nbsp; The only thing I&amp;#39;m unhappy about - I&amp;#39;ve been able to find ANYTHING as far as an automated &amp;quot;binding&amp;quot; of solutions to TFS.&amp;nbsp; So my users will need to manually do this as they edit reports.&amp;nbsp; Many haven&amp;#39;t been touched since they were written in 2006 - so this is hopefully not a big deal...&lt;/p&gt;&lt;p&gt;Here&amp;#39;s the script in all it&amp;#39;s glory&amp;nbsp;&lt;/p&gt;&lt;p&gt;$Folder = &amp;quot;C:\File13\StARS.Reports&amp;quot;&lt;br /&gt;#first clear the read-only flag from all files&lt;br /&gt;get-childitem &amp;quot;$folder&amp;quot; -Recurse | % {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Test for ReadOnly flag and remove if present &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($_.attributes -band [system.IO.FileAttributes]::ReadOnly) {&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $_.attributes = $_.attributes -bxor [system.IO.FileAttributes]::ReadOnly &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;}&lt;/p&gt;&lt;p&gt;#next delete all files that are *.suo, *.user, and *.*scc - we don&amp;#39;t want thim in TFS&lt;br /&gt;Get-ChildItem&amp;nbsp; $folder *.suo -Recurse -Force | Remove-Item -Force&lt;br /&gt;Get-ChildItem&amp;nbsp; $folder *.*scc -Recurse -Force | Remove-Item -Force&lt;br /&gt;Get-ChildItem&amp;nbsp; $folder *.user -Recurse -Force | Remove-Item -Force&lt;/p&gt;&lt;p&gt;#next get all the .sln file - and remove the VSS binding information&lt;br /&gt;$files = Get-ChildItem $folder *.sln -Recurse &lt;br /&gt;foreach ($file in $files) {&lt;br /&gt;&amp;nbsp;$fileout = $file.FullName + &amp;quot;.new&amp;quot;&lt;br /&gt;&amp;nbsp;Set-Content $fileout $null&lt;br /&gt;&amp;nbsp;$switch=0&lt;br /&gt;&amp;nbsp;Get-Content $file.FullName | % {&lt;br /&gt;&amp;nbsp;&amp;nbsp;if ($switch -eq 0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($_&amp;nbsp; -eq &amp;quot;&amp;nbsp;GlobalSection(SourceCodeControl) = preSolution&amp;quot;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#we found the section to skip - so set the flag and don&amp;#39;t copy the content&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$switch=1}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#we haven&amp;#39;t found it yet - so copy the content&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Add-Content $fileout $_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;elseif ($switch -eq 1) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ($_ -eq &amp;quot;&amp;nbsp;EndGlobalSection&amp;quot;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#last line to skip - after it we start writing the content again&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$switch=2}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;&amp;nbsp;else &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;#write remaining lines&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Add-Content $fileout $_}&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;#remove the original .sln and rename the new one&lt;br /&gt;&amp;nbsp;$newname = $file.Name&lt;br /&gt;&amp;nbsp;Remove-Item $file.FullName&lt;br /&gt;&amp;nbsp;Rename-Item $fileout -NewName $newname&lt;br /&gt;}&lt;br /&gt;##next we need to remove the &amp;lt;State&amp;gt; Node from the .rptproj files - it also contains binding information&lt;br /&gt;$files = Get-ChildItem $folder *.rptproj -Recurse &lt;br /&gt;foreach ($file in $files) {&lt;br /&gt;&amp;nbsp;#read the project file as XML&lt;br /&gt;&amp;nbsp;$proj = [xml] [string]::Join(&amp;quot;`n&amp;quot;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;(get-content&amp;nbsp; $file.FullName))&lt;br /&gt;&amp;nbsp;$stateNode = $proj.SelectNodes(&amp;quot;/Project/State&amp;quot;)&lt;br /&gt;&amp;nbsp;$root = $proj.Project&lt;br /&gt;&amp;nbsp;[Void]$root.RemoveChild($stateNode.item(0))&lt;br /&gt;&amp;nbsp;#save file todo&lt;br /&gt;&amp;nbsp;$proj.Save($file.FullName)&lt;br /&gt;}&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=7297" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author><category term="TFS" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/TFS/default.aspx" /><category term="Powershell" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/Powershell/default.aspx" /></entry><entry><title>Error loading SSRS Report Project in VS2005: &quot;Could not load file or assembly 'ReportingServicesLibrary, Version=9.0.242.0&quot;</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/11/13/Error-loading-SSRS-Report-Project-in-VS2005_3A00_-_2200_Could-not-load-file-or-assembly-_2700_ReportingServicesLibrary_2C00_-Version_3D00_9.0.242.0_2200_.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/11/13/Error-loading-SSRS-Report-Project-in-VS2005_3A00_-_2200_Could-not-load-file-or-assembly-_2700_ReportingServicesLibrary_2C00_-Version_3D00_9.0.242.0_2200_.aspx</id><published>2008-11-13T16:51:00Z</published><updated>2008-11-13T16:51:00Z</updated><content type="html">&lt;p&gt;I had this problem and &amp;quot;Google&amp;#39;ing&amp;quot; it turned up nothing relevant.&amp;nbsp; So obviously this is prime material for blogging about it...&lt;/p&gt;&lt;p&gt;The background is that I returned to a client I had previously consulted for after a couple months.&amp;nbsp; They had deleted and added an account for me on their domain - so I when I logged into the Virtual PC I use for their domain - Windows considered it a new account (I think this may have had something to do with the problem but who knows).&amp;nbsp; I had used that VPC for over two years - and had installed various different editions of Visual Studio 2005 over that period.&lt;/p&gt;&lt;p&gt;I&amp;#39;m working on migrating their applications from VSS (and a custom-baked build system) to Team Foundation Server and my last project is for their&amp;nbsp;SSRS projects.&amp;nbsp; But every single report I tried loading gave me a couple of errors.&amp;nbsp; This happened whether I opened the solution or the Report Project (*.rptproj)&amp;nbsp; First I got the error: &amp;quot;&lt;font color="#810081"&gt;Project item &amp;#39;#item&amp;deg;#&amp;#39; does not represent a file.&lt;/font&gt; &amp;quot; That workaround was to manually edit the rprtproj and remove the &amp;quot;&amp;lt;State&amp;quot;&amp;gt; element.&amp;nbsp; I also so entries complaining that the *.user files should not be checked into version control - (which they were) - so I deleted those as well...&lt;/p&gt;&lt;p&gt;&amp;nbsp;But when I cleared those errors - I started getting the &amp;quot;&amp;quot;Could not load file or assembly &amp;#39;ReportingServicesLibrary, Version=9.0.242.0&amp;quot; error.&amp;nbsp; I was stumped - and tried to look around for solutions.&amp;nbsp; I contacted the Release Manager (who I report to) to discuss it - in a previous position - she had developed quite a few of those reports- who suggested if when I do a &amp;quot;New Project&amp;quot; wizard - if the&amp;nbsp;templates for &amp;quot;Business Intelligence Projects&amp;quot; was an option - and it wasn&amp;#39;t!&amp;nbsp; Somehow that package got corrupt in my install of VS 2005.&amp;nbsp; &lt;/p&gt;&lt;p&gt;I have a good idea that it happened when &amp;quot;mucking around&amp;quot; in the &amp;quot;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies&amp;quot; directory - but that&amp;#39;s another story...&lt;/p&gt;&lt;p&gt;I found some google posts on some fixes - but nothing worked - until I went to the extreme measure of COMPLETELY uninstalling ALL of Visual Studio 2005.&amp;nbsp; I then had to completely uninstall ALL of SQL Server 2005.&amp;nbsp; Then I had to reinstall everything.&amp;nbsp; This was no small task - but it did finally work in the end.&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=7138" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>Cool Powershell Trick - Stopping and Starting a service on a remote server without having to explicitly load the .NET assemblies</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/10/29/Cool-Powershell-Trick-_2D00_-Stopping-and-Starting-a-service-on-a-remote-server-without-having-to-explicitly-load-the-.NET-assemblies.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/10/29/Cool-Powershell-Trick-_2D00_-Stopping-and-Starting-a-service-on-a-remote-server-without-having-to-explicitly-load-the-.NET-assemblies.aspx</id><published>2008-10-29T17:56:00Z</published><updated>2008-10-29T17:56:00Z</updated><content type="html">&lt;p style="margin-left:0in;"&gt;&lt;span style="font-size:11pt;font-family:'Calibri','sans-serif';"&gt;I was chatting with my colleague at Magenic Donn Felker about two of our favorite topics TFS and Powershell.&amp;nbsp; He found a cool way to load scripts into a profile.&amp;nbsp; It reminded me of a cool Powershell Trick i found on the web before I started blogging...&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-left:0in;"&gt;&lt;span style="font-size:11pt;font-family:'Calibri','sans-serif';"&gt;I wrote deployment scripts in Powershell, which the client wanted to run on a single server regardless of where they were deploying to - so I needed to stop and start services on a remote machine.&amp;nbsp; However, the current version of Powershell doesn&amp;#39;t include direct support for managing services on&amp;nbsp;a remote server.&amp;nbsp; The solution (as is so often the case in Powershell is to use .NET Framework classes).&amp;nbsp; To do so - you generally need to load the Assemblies explicitly with code that looks like this&lt;/span&gt;&lt;/p&gt;&lt;p class="Code" style="margin:auto 0in auto 0.5in;"&gt;&lt;font face="Courier New"&gt;#load assemblies&lt;br /&gt;$key = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\VisualStudio\9.0&lt;br /&gt;$dir = [string] (Get-ItemProperty $key.InstallDir)&lt;br /&gt;$dir += &amp;quot;PrivateAssemblies\&amp;quot;&lt;br /&gt;#set to $x so it won&amp;#39;t emit the &amp;quot;success&amp;quot; to the output stream&lt;br /&gt;$lib = $dir + &amp;quot;Microsoft.TeamFoundation.Client.dll&amp;quot;&lt;br /&gt;$x=[Reflection.Assembly]::LoadFrom($lib)&lt;br /&gt;$lib = $dir + &amp;quot;Microsoft.TeamFoundation.VersionControl.Client.dll&amp;quot;&lt;br /&gt;$x=[Reflection.Assembly]::LoadFrom($lib)&lt;/font&gt;&lt;/p&gt;&lt;p style="margin-left:0in;"&gt;&lt;span style="font-size:11pt;font-family:'Calibri','sans-serif';"&gt;So with the assemblies loaded you can call methods on the classes they implement like this:&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0in 0in 0pt;text-indent:0.5in;"&gt;&lt;span style="font-size:9pt;font-family:'Courier New';"&gt;#Set up connection to TFS Server &lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;font-family:'Courier New';"&gt;$tfs = [Microsoft.TeamFoundation.Client.TeamFoundationServerFactory]::GetServer($tfsServer)&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;font-family:'Courier New';"&gt;#get version control$versionControlType = [Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer]&lt;span&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;font-family:'Courier New';"&gt;$versionControlService = $tfs.GetService($versionControlType)&lt;/span&gt;&lt;span style="font-size:10pt;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;(This sample above is to load assemblies to use the TFS Version Control API)&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;So you pretty much need to know where the Assembly is loaded from, and use the Reflection.Assembly class to load it.&lt;/font&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Here&amp;rsquo;s the trick.&lt;span&gt;&amp;nbsp; &lt;/span&gt;While the Powershell &amp;ldquo;Cmdlets&amp;rdquo; to manipulate services only work on the machine the script is running on, they use the .NET framework classes &amp;ldquo;behind the scenes&amp;rdquo; so if you execute the &amp;ldquo;Get-Services&amp;rdquo; cmdlet &amp;ndash; all the dependent assemblies are automatically loaded in your process space.&lt;span&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;So the code below works without having to explicitly load any assemblies!I&lt;/font&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;# dummy run of Get-Service CMDLet to force .NET Assemblies to be loaded&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;$dmy = Get-Service&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;#Get the services on the Remote Machine&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;$allServices = [System.ServiceProcess.ServiceController]::GetServices($NSServer)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;#Get the NS Service&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;$nsService = $allServices | where {$_.Name -like &amp;#39;NS$steriworksinstance&amp;#39;}&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;#Call Stop on the Service if it is Running - if so stop it&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;if ($nsService.Status -eq &amp;quot;Running&amp;quot;)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;$nsService.Stop()&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;}&lt;/span&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;While this might &amp;ldquo;break&amp;rdquo; in a future release of Powershell, they are adding support for remote servers, so switching to the cmdlets for that would be preferred anyway&amp;hellip;&lt;/font&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;Oh and in case you are interested - the code to start the service&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:9pt;line-height:115%;font-family:'Courier New';"&gt;&amp;nbsp;$nsService.Start()&lt;br /&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=6915" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author><category term="Powershell" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/Powershell/default.aspx" /></entry><entry><title>Extending TFS Presentation</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/10/07/Extending-TFS-Presentation.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/10/07/Extending-TFS-Presentation.aspx</id><published>2008-10-07T14:24:00Z</published><updated>2008-10-07T14:24:00Z</updated><content type="html">&lt;p&gt;I&amp;#39;ve given&amp;nbsp;the presentation &amp;quot;Extending Team Foundation Server 2008-SP1 &amp;quot; twice in the past couple of months: at &amp;quot;Codeapalooza&amp;quot; on September 6, 2008 and at the Chicago VSTS User&amp;#39;s group last week on October 2, 2008.&amp;nbsp; I&amp;#39;ve had at least one attendee ask for a copy of the Slides and the Proof-of-Concept code.&amp;nbsp; Both the code and the slides can be downloaded &lt;a href="http://www.codeapalooza.com/downloads/DanSniderman-ExtendTFS.zip" title="Presentation files download"&gt;here&lt;/a&gt;.&amp;nbsp; In this presentation I discussed some different ways TFS can be extended with detailed examples.&amp;nbsp; For the TFS API, I walk-through code for a Proof-of-Concept I wrote which will create &amp;quot;Bug&amp;quot; Work Items for unhandled exceptions.&lt;/p&gt;&lt;p&gt;If you are involved with a users&amp;#39; group or similar organization in the Midwest and would be interested in this presentation I&amp;#39;d be happy to do so!&amp;nbsp; Please contact me using the email link to the right.&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=6533" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>Implementing VB6 on TFS</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/08/27/Implementing-VB6-on-TFS.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/08/27/Implementing-VB6-on-TFS.aspx</id><published>2008-08-27T20:13:00Z</published><updated>2008-08-27T20:13:00Z</updated><content type="html">&lt;p&gt;I just finished implementing VB6 build for my client.&amp;nbsp; It was pretty easy, but I learned a few things.&lt;/p&gt;&lt;p&gt;To do it, I simply added the source code to Version Control (naturally).&amp;nbsp; Then created a build type like any but with one exception.&amp;nbsp; Obviously I couldn&amp;#39;t use the &amp;quot;Create Project File&amp;quot; Wizard, since there will be no SLN Solution file to find, so I created the TFSBuild.proj&amp;nbsp;entirely manually before creating the Build Type.&amp;nbsp; In that project I added the following:&lt;/p&gt;&lt;p&gt;PropertyGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;VB6&amp;gt;$(ProgramFiles)\Microsoft Visual Studio\VB98\VB6.exe&amp;lt;/VB6&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;VB6Output&amp;gt;$(BinariesRoot)\VB6\&amp;lt;/VB6Output&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;VB6Timeout&amp;gt;150000&amp;lt;/VB6Timeout&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/PropertyGroup&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;lt;ItemGroup&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;ProjectToBuild Include=&amp;quot;$(SolutionRoot)\Source\[ApplicationDirectory]\{application].vbp&amp;quot;&amp;gt;&amp;lt;/ProjectToBuild&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;lt;/ItemGroup&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;Target Name=&amp;quot;CoreCompile&amp;quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;lt;Message Text=&amp;quot;CompileProject: %(ProjectToBuild.Identity)&amp;quot;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;lt;MakeDir Directories=&amp;quot;$(VB6Output)&amp;quot; Condition=&amp;quot;!Exists(&amp;#39;$(VB6Output)&amp;#39;)&amp;quot;/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;lt;Exec Condition=&amp;quot; &lt;a href="mailto:&amp;#39;@(ProjectToBuild)&amp;#39;!=&amp;#39;&amp;#39;"&gt;&amp;#39;@(ProjectToBuild)&amp;#39;!=&amp;#39;&amp;#39;&lt;/a&gt; &amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Command=&amp;quot;&amp;amp;quot;$(VB6)&amp;amp;quot; /m &amp;amp;quot;%(ProjectToBuild.Identity)&amp;amp;quot; /outdir &amp;amp;quot;$(VB6Output)&amp;amp;quot; /out &amp;amp;quot;$(VB6Output)VB6.log&amp;amp;quot;&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timeout=&amp;quot;$(VB6Timeout)&amp;quot;/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;lt;/Target&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;With that, I got a good VB6 Build!&lt;/p&gt;&lt;p&gt;The next thing I did was put the standard customization the client uses for it&amp;#39;s Build Number/Version Stamping.&amp;nbsp; Once the Build Number was calculated, we edit files appropriately to get that into the EXE&amp;#39;s and DLL&amp;#39;s - the heavy lifting done using the Tigris MSBuild Community Tasks.&amp;nbsp; This always worked fine but when I added it to my VB6 Solution, VB6 wouldn&amp;#39;t compile with the message: &lt;/p&gt;&lt;p&gt;The project file &amp;#39;c:\TFSBuild\23\Sources\Source\[ApplicationDirectory]\[application].vbp&amp;#39; contains invalid key &amp;#39;﻿Type&amp;#39;. &lt;/p&gt;&lt;p&gt;With a &amp;quot;garbage&amp;quot; character in front of the capital &amp;quot;T&amp;quot; of Type.&lt;/p&gt;&lt;p&gt;Well once again, the same issue I blogged about a few months ago: &lt;a href="http://blog.magenic.com/blogs/daniels/archive/2008/06/18/UTF_2D00_8-is-NOT-ASCII_2100_.aspx"&gt;UTF-8 is not ASCII&lt;/a&gt;! Evidently VB6 can&amp;#39;t handle UTF-8 encoded files, which is the default in .NET.&amp;nbsp; Fortunately, the &amp;lt;FileUpdate&amp;gt; tasks exposes the &amp;quot;Encoding&amp;quot; Property to the tasks, so specifying &amp;quot;Encoding=ascii&amp;quot; solved the problem!&lt;/p&gt;&lt;p&gt;The other issue I had was with the installer for the TFS MSSCCI Provider.&amp;nbsp; This is a plug-in for &amp;quot;legacy&amp;quot; applications (like Visual Studio 6 and Visual Studio 2003 for example) to use TFS.&amp;nbsp; I had installed an earlier version (and had successfully checked-in and out VB6 modules from VS6 and TFS Version Control).&amp;nbsp; I saw that a new version of the Provider was released in early August (to support SP1 of TFS2008 I would guess in addition to some new features) - so I installed it.&amp;nbsp; It had an MSI - so I assumed that it could handle dealing with earlier versions.&lt;/p&gt;&lt;p&gt;I then tried to check-out files and got a cryptic error: &lt;/p&gt;&lt;p&gt;&amp;quot;method not found: Void Microsoft.TeamFoundation.Msscci.Client.Context.EditItems(System.String[], Microsoft.TeamFoundation.VersionControl.Client.RecursionType, Microsoft.TeamFoundation.VersionControl.Client.LockLevel,&amp;quot;&lt;/p&gt;&lt;p&gt;Using Reflector I found that, in fact, such an overload did not exist.&amp;nbsp; So after some digging I noticed two entries in &amp;quot;Add/Remove Programs&amp;quot; for the MSSCCI Provider.&amp;nbsp; Evidently installing the new version on top of the old one breaks it.&amp;nbsp; Here is what I had to do to fix it:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;div&gt;Uninstall one of the Entries in Add/Remove Programs&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;If you try to uninstall the second (now only remaining one) you get an error - so - &lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Double-click the installer (MSI) for the second one, and choose &amp;quot;Repair&amp;quot;&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Now you can uninstall the remaining entry&lt;/div&gt;&lt;/li&gt;&lt;li&gt;&lt;div&gt;Install the newest version&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Voil&amp;agrave;, the MSSCCI provider works find in VB6 (or anywhere else for that matter).&amp;nbsp; So the moral of the story, if you use TFS with the provider, whenever a new release comes out, make sure to manually unintall it before installing the new one.&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=5854" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author><category term="TFS" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/TFS/default.aspx" /><category term="VB6" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/VB6/default.aspx" /></entry><entry><title>Fun with VS2008SP1 and VPC</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/08/24/Fun-with-VS2008SP1-and-VPC.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/08/24/Fun-with-VS2008SP1-and-VPC.aspx</id><published>2008-08-24T17:06:00Z</published><updated>2008-08-24T17:06:00Z</updated><content type="html">&lt;p&gt;So I&amp;#39;m preparing for my presentation at the Upcoming &lt;a href="http://www.codeapalooza.com/" title="Codeapalooza" target="_blank"&gt;Codeapalooza&lt;/a&gt; event: which will be Saturday September 6 at 2:30 PM in Wheaton (like how I got a little plug in on this blog post?).&amp;nbsp; This will be a &amp;quot;hands-on&amp;quot; presentation so I have a separate Virtual PC representing the Client workstation from my TFS Virtual Server.&amp;nbsp; Naturally I want to demo with the latest and greatest, so I upgraded my TFS Virtual Server (installed on Windows Server 2003) and the Client (Windows Vista Business) both with their corresponding Service Pack installs.&lt;/p&gt;&lt;p&gt;I had zero issues with the TFS server, both the Visual Studio SP (since I have Team System Web Access installed I have to have Team Explorer installed).&amp;nbsp;But I&amp;#39;m chugging along on the client and decide to add some stuff to source code.&amp;nbsp; Since I&amp;#39;m used to SP1 features (man, it doesn&amp;#39;t take very long does it?) I try to drag a folder from Windows Explorer to Source Code Explorer in Team Explorer (I think I just lost a few IQ points typing that..)&amp;nbsp; But nothing happened!&lt;/p&gt;&lt;p&gt;Hmm, something clearly isn&amp;#39;t right.&amp;nbsp; I discover, somehow, the SP1 installer, which reported no errors, didn&amp;#39;t upgrade the Team Explorer component.&amp;nbsp; Well at first I figure I can (unhappily) live without those features, until I get a Work-Item customized.&amp;nbsp; Then, every time I tried to open the Work Item forms from Team Explorer I get a &amp;quot;Could not load type &amp;#39;Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemTypeDeniedOrNotExistException&amp;#39; from assembly &amp;#39;Microsoft.TeamFoundation.WorkItemTracking.Client&amp;quot; exception.&amp;nbsp; When I first saw that I thought I might have made a mistake with the customization, so I open the item up in TSWA and no error.&amp;nbsp; Same with Team Explorer run directly on the TFS server.&lt;/p&gt;&lt;p&gt;The funny thing, everything works fine on the client, I just constantly got that error (and I mean constantly, every time I opened a Work Item, ran a query, or whatever).&amp;nbsp; The &amp;quot;annoyance factor&amp;quot; overrode the &amp;quot;nothing is broke but the error message so I can live with it&amp;quot; factor&amp;nbsp;(especially given that I am planning on demoing with the VPC and would look pretty shabby with a &amp;quot;Yeah, I get this error all the time, just ignore it&amp;quot; in my presentation.&lt;/p&gt;&lt;p&gt;So I decide I had to fix it.&amp;nbsp; Not much info out there on google beyond&amp;nbsp;what I already knew&amp;nbsp;(you get this when SP1 isn&amp;#39;t installed).&amp;nbsp; So next I tried to re-install SP1, but no dice.&amp;nbsp; For some reason the installer for SP1 just didn&amp;#39;t recognize that I had Team Explorer installed, so it didn&amp;#39;t update it.&lt;/p&gt;&lt;p&gt;So my only recourse was to uninstall Visual Studio 2008 and reinstall the application and the Service pack.&amp;nbsp; The interesting thing, when I did reinstall VSTS 2008, (from the Team Suite Edition I got from a MSDN subscription, which I have a copy of thanks to my former colleague and Team System MVP &lt;a href="http://sstjean.blogspot.com/" target="_blank"&gt;Steve St. Jean&lt;/a&gt;).&amp;nbsp; Before I installed SP1, I decided to run Visual Studio 2008.&amp;nbsp; And the curious thing,&amp;nbsp;this time Team Explorer didn&amp;#39;t get included automatically.&amp;nbsp; I had to do a separate install.&amp;nbsp; I&amp;#39;m not sure why - but it likely had something to do with the previous issues.&lt;/p&gt;&lt;p&gt;I then proceeded to install SP1 and this time, Team Explorer got updated properly as expected.&amp;nbsp; The downside, on a Virtual Machine, even on a host with a decent processor (Intel Q6600) and 4GB of memory, it took a significant amount of time.&lt;/p&gt;&lt;p&gt;Perhaps there were other work-arounds that would have been accomplished faster, but I do think a straight uninstall/reinstall is &amp;quot;cleanest&amp;quot;.&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=5795" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>Output Issue with Transcript in Powershell</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/07/14/Output-Issue-with-Transcript-in-Powershell.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/07/14/Output-Issue-with-Transcript-in-Powershell.aspx</id><published>2008-07-14T14:30:00Z</published><updated>2008-07-14T14:30:00Z</updated><content type="html">&lt;p class="MsoNormal" style="margin:0in 0in 10pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;As I mentioned in my previous blog post, there is a &amp;quot;bug&amp;quot; in the current version of Powershell with the Transcript.&amp;nbsp; For &amp;quot;external&amp;quot; commands, (that is programs that aren&amp;#39;t Powershell commands) the transcript will log the input but not output.&amp;nbsp; I first encountered this when I started calling &amp;quot;Robocopy&amp;quot; instead of &amp;quot;Copy-Item&amp;quot; because of the speed and features Robocopy provides over the native &amp;quot;copy-item&amp;quot; command.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;My work around is very simple.&amp;nbsp; I need to capture the output anyway to determine if there is an error.&amp;nbsp; So I assign the output stream from Robocopy to a variable and then simply use &amp;quot;Write-Output&amp;quot; to display it in the stream.&amp;nbsp; The drawback is that the interactive user is going to have to wait until the command has completed to see the output - but again, I need to parse the output for errors - so not much I can do about that.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;Here&amp;#39;s my code snippet:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;using Robocopy for speed and more power with exlusion&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;&amp;quot;copying files with robocopy with the following command: $exec&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;$exec=&amp;quot;robocopy $sourcePath $destPath /XD _config* Deploy /s&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;$out = Invoke-Expression&amp;nbsp; $exec&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;#write the log to stream&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;Write-Output $out&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;#check if there was an error&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;$fail = $out -match &amp;quot;ERROR :&amp;quot; &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;if ($fail)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw(&amp;quot;Failure in deploying ProcessLauncher Files&amp;quot;)&lt;/span&gt;&lt;span style="font-size:9pt;color:yellow;font-family:'Courier New';"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;color:yellow;font-family:'Courier New';"&gt;}&lt;/span&gt;&lt;span style="font-size:9pt;color:yellow;font-family:'Arial','sans-serif';"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;Another solution was provided by a reader to the blog Seb from New Zealand (thanks for reading Zeb!) which he got from the Microsoft Powershell Newsgroup:&amp;nbsp; which is to use:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:9pt;font-family:'Arial','sans-serif';"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt 0.5in;line-height:normal;"&gt;&lt;span style="font-size:9pt;background:blue;color:yellow;font-family:'Courier New';"&gt;Function Fix-Transcript () &lt;br /&gt;{ &lt;br /&gt;Process{ &lt;br /&gt;Write-Host $_ &lt;br /&gt;} &lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;ipconfig | Fix-Transcript &lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:9pt;background:blue;font-family:'Verdana','sans-serif';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:8pt;background:blue;color:yellow;font-family:'Courier New';"&gt;Stop-Transcript&lt;/span&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman','serif';"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;line-height:normal;"&gt;&lt;span style="font-size:10pt;font-family:'Arial','sans-serif';"&gt;While it&amp;rsquo;s a little &amp;ldquo;noisier&amp;rdquo; I think I prefer the Write-Output as I think it is a little clearer what&amp;rsquo;s happening.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 10pt;"&gt;&lt;font face="Calibri" size="3"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=5011" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>&quot;Logging&quot; Script Output in Powershell</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/07/12/_2200_Logging_2200_-Script-Output-in-Powershell.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/07/12/_2200_Logging_2200_-Script-Output-in-Powershell.aspx</id><published>2008-07-12T13:41:00Z</published><updated>2008-07-12T13:41:00Z</updated><content type="html">&lt;p&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;I&amp;#39;ve been using Powershell for deploy scripts from TFS builds at my current gig.&amp;nbsp; I COULD have used MSBuild, but I chose Powershell for a number of reasons (which I&amp;#39;ll detail in a future article on the subject).&amp;nbsp; One important feature (particularly for something like deploying &amp;quot;bits&amp;quot; to production) is to save&amp;nbsp;a &amp;quot;log&amp;quot; of all output from the script.&amp;nbsp; In case of failure, you&amp;#39;ll want to review the errors.&amp;nbsp; For troubleshooting in the future, it&amp;#39;s especially important to know what files were copied etc.&amp;nbsp; And auditors love stuff like that...&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&amp;nbsp;A long time ago, in a technology far far away, I wrote database scripts for a Sybase database on UNIX using Kornshell - so I have some (albeit decade old) experience with scripting.&amp;nbsp; Normally you would create the &amp;quot;log&amp;quot; by re-directing the output from the script to a file.&amp;nbsp; The problem is that you have to wait for the script to finish and type a command to see the results.&amp;nbsp; So I would use the &amp;quot;tee&amp;quot; command that would split the output to the console and a file.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&amp;nbsp;When writing my Powershell scripts I found they have the &amp;quot;tee-object&amp;quot; so all was good.&amp;nbsp; I called my script with a line like this:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;.{.\_DeployHostApplication.ps1 -Env QA&amp;nbsp;-WebTargetName &amp;quot;\\corpgp01\ARCS-Services-bin&amp;quot;} | tee-object $file&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;&lt;/span&gt;&lt;span style="font-size:8pt;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;The problem, tee-object only copies the &amp;quot;success&amp;quot; output-stream and not errors.&amp;nbsp; In Kornshell there was stdout and stderr and you could redirect with 2&amp;gt;&amp;amp; (or some such completely obscure and unreadable syntax, it&amp;#39;s been a while) that redirects both output streams.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;So doing research with the handy tool known as &amp;quot;Google&amp;quot; I looked at various approaches and found out that Powershell has a feature built in (ah those Powershell authors are so smart!) with commands &amp;quot;start-transcript&amp;quot; and &amp;quot;stop-transcript&amp;quot; that writes all output automagically to a file!&amp;nbsp; This was EXACTLY what I needed!&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;The only issue, without error control, if a severe error occurs that causes the script to fail, the &amp;quot;stop-transcript&amp;quot; won&amp;#39;t execute.&amp;nbsp; That &amp;quot;transcripting&amp;quot; continues and everything you type at the Powershell command line continues to be written to the file.&amp;nbsp; (I was getting &amp;quot;recursive like behavior as I was typing the log file and it would append the output, doubling the size of the log as it went on!).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;But this is no problem in Powershell as it has Error Trapping built in.&amp;nbsp; It&amp;#39;s sort of like the old classic VB &amp;quot;On Error&amp;quot; (as opposed to Try-Catch) where you have a script block that executes if an error occurs.&amp;nbsp; So I wrapped the stop-transcript command in an error trap and all was fine.&amp;nbsp; Here is the new code:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;$dt = Get-Date -format &amp;quot;yyyyMMdd_hhmm&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;$log = ($MyInvocation.MyCommand.Name).Replace(&amp;quot;.ps1&amp;quot;,&amp;quot;_$dt.log&amp;quot;)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;$file = &amp;quot;..\..\&amp;quot; + $log&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;start-transcript $file&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;trap { stop-transcript; break}&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;.\_DeployHostApplication.ps1 -Env QA -WebTargetName &lt;a&gt;&lt;font color="#0000ff"&gt;\\corpgp01\ARCS-Services-bin&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;background:yellow;font-family:Arial;"&gt;stop-transcript&lt;/span&gt;&lt;span style="font-size:8pt;font-family:Arial;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;So here is the final script.&lt;span&gt;&amp;nbsp; &lt;/span&gt;The first three lines determine the filename I want to log to.&lt;span&gt;&amp;nbsp; &lt;/span&gt;The name will match the Powershell script name with a date and time stamp followed by &amp;ldquo;.log&amp;rdquo; instead of &amp;ldquo;.ps1&amp;rdquo; and two directory tree levels above where the script was located.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Lines 4-5 start the transcript, and uses the error trapping code to stop the transcript and then break out of the script (alternatively I could use &amp;ldquo;continue&amp;rdquo; instead of &amp;ldquo;break&amp;rdquo; to continue the DeployHostApplication script instead of breaking at the line that caused the error)&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;Line 6 executes my script, and line 7 will do the stop-transcript when there are no errors.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt;"&gt;&lt;span style="font-size:10pt;font-family:Arial;"&gt;The only other issue I want to mention, &amp;ldquo;stop-transcript&amp;rdquo; only writes POWESHELL output.&lt;span&gt;&amp;nbsp; &lt;/span&gt;A subsequent blog post will show how I solved that issue&amp;hellip;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin:0in 0in 0pt 0.5in;"&gt;&lt;span style="font-size:8pt;font-family:Arial;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=4978" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>I'm a published author!</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/06/18/I_2700_m-a-published-author_2100_.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/06/18/I_2700_m-a-published-author_2100_.aspx</id><published>2008-06-18T18:09:00Z</published><updated>2008-06-18T18:09:00Z</updated><content type="html">&lt;p&gt;My article &amp;quot;An Introduction to Continuous Integration with Team Foundation Server 2008&amp;quot; was published in the June 2008&amp;nbsp;Edition of .NET Developer&amp;#39;s Journal!&amp;nbsp; The PDF can be viewed&amp;nbsp;&amp;nbsp; The URL is:&amp;nbsp;&lt;a href="http://pdf.sys-con.com/Dotnet/Walk_Spread.pdf" title="http://pdf.sys-con.com/Dotnet/Walk_Spread.pdf "&gt;http://pdf.sys-con.com/Dotnet/Walk_Spread.pdf &lt;/a&gt;&amp;nbsp; (I think that may only be valid while it&amp;#39;s the &amp;quot;current issue&amp;quot; and back issues require a paid subscription...)&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=4633" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>UTF-8 is NOT ASCII!</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/06/18/UTF_2D00_8-is-NOT-ASCII_2100_.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/06/18/UTF_2D00_8-is-NOT-ASCII_2100_.aspx</id><published>2008-06-18T14:42:00Z</published><updated>2008-06-18T14:42:00Z</updated><content type="html">&lt;p&gt;At my current client we had an interesting (and probably very common issue).&amp;nbsp; The project we&amp;#39;re on is to integrate my client&amp;#39;s internal accounting applications (a mixture of Microsoft Dynamics 6.5 and custom applications) with &amp;quot;GetPaid&amp;quot; from Sungard.&amp;nbsp; The vendor asked for a file, we asked what encoding they wanted and they stated &amp;quot;UTF-8&amp;quot;.&amp;nbsp; We produced the software to extract the data and run the vendor&amp;#39;s utility code to load it - and it fails because of &amp;quot;bad data&amp;quot; in the comments field.&lt;/p&gt;&lt;p&gt;The comments field is a free form field for a customer.&amp;nbsp; My client&amp;#39;s intrepid QA Tester showed screen shots of the data in the&amp;nbsp;Accounting System that had no issues, but did include a backwards quote (apostrophe, accent grave or whatever you want to call it).&amp;nbsp; My colleague from Magenic Scott Janssens had written a general-purpose C# utility that took an XML document as input which would specify a stored procedure name and specifications to convert columns from the query to text.&amp;nbsp; As instructed, Scott specified UTF-8 encoding.&lt;/p&gt;&lt;p&gt;Scott did some research (a cautious developer always takes into consideration THEY did something wrong).&amp;nbsp; A further bit of confusion being the database in question was SQL 2000.&amp;nbsp; SQL 2000 doesn&amp;#39;t use UTF-8 but the now obsolete UCS-2.&amp;nbsp; But ADO.NET makes that conversion without any issue.&lt;/p&gt;&lt;p&gt;Scott researched the issue and&amp;nbsp;explains it as well (or better) than I can as follows:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Here&amp;#39;s the skinny on encoding:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Firstly, UTF-8 is not ASCII.&amp;nbsp; I had this wrong and I suspect SunGard is mistaken in the same way I was.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;ASCII (aka ANSI, aka Plain Text) stores a character using a single byte.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;UTF-8 is a Unicode encoding which stores a character using 1, 2, 3, or 4 bytes.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;In UTF-8 all the ASCII characters are represented with one byte.&amp;nbsp; This makes UTF-8 backwards compatible with ASCII.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The problem we&amp;#39;re seeing is when the UTF-8 text in the database contains non-ASCII characters.&amp;nbsp; In the case below, the character is a Unicode apostrophe.&amp;nbsp; This is different than the ASCII apostrophe.&amp;nbsp; The Unicode apostrophe is represented by three bytes.&amp;nbsp; When read with the proper encoding these three bytes display as an apostrophe.&amp;nbsp; When read with the ASCII encoding, each of the three bytes is displayed (because the encoding assumes each byte is a character) with whatever ASCII characters the byte values correspond to.&amp;nbsp; The result is gibberish.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;These values in the database are probably the result of the user cutting and pasting text from Word or Outlook.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The file we&amp;#39;re sending Sungard is currently encoded in UTF-8.&amp;nbsp; I suspect they want it in ASCII.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Depending on the needs of the project sending the data in ASCII may or may not be an issue.&amp;nbsp; When converting to ASCII, any character that doesn&amp;#39;t exist in ASCII is replaced with a question mark.&amp;nbsp; So in our example below, &amp;quot;doesn&amp;#39;t&amp;quot; becomes &amp;quot;doesn?t&amp;quot;.&amp;nbsp; If we need to keep the strings as they appear in our database, Sungard will need to properly read UTF-8.&amp;nbsp; If we don&amp;#39;t care about non-ASCII characters appearing as question marks, then we can send the data to Sungard in ASCII format.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;The change to make the converter output ASCII is a one line change, changing the encoding object from UTF8Encoding to ASCIIEncoding.&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Interesting stuff - good work Scott!&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=4632" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>Found a Bug in Team Build</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/04/24/Found-a-Bug-in-Team-Build.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/04/24/Found-a-Bug-in-Team-Build.aspx</id><published>2008-04-24T16:21:00Z</published><updated>2008-04-24T16:21:00Z</updated><content type="html">&lt;p&gt;I reported a problem on the MSDN TFS Build Automation Forum and Jason Pricket from Microsoft verified that it is, in fact, a bug in TFS 2008.&amp;nbsp; My client previously hasn&amp;#39;t used CI - so I setup the builds for the Application in TFS as &amp;quot;Daily Builds&amp;quot;.&amp;nbsp; Or specifically the build&amp;#39;s &amp;quot;Trigger&amp;quot; is &amp;quot;Build Every Week on the following Days&amp;quot; with Monday through Friday checked.&amp;nbsp; There&amp;#39;s also a Check box for &amp;quot;Build even if nothing has changed&amp;quot; - which I have UNchecked.&lt;/p&gt;&lt;p&gt;&amp;nbsp;The issue is that I have build automation using a task from &lt;a href="http://msbuildtasks.tigris.org/"&gt;MS Build Community Tasks&lt;/a&gt;&amp;nbsp;that takes a version number from a Text File to ultimately update the Assembly Version, which I of course then check-back in to Version Control.&amp;nbsp; Obviously, I don&amp;#39;t want &lt;strong&gt;that &lt;/strong&gt;check-in to be considered when evaluating whether &amp;quot;nothing has changed&amp;quot;&lt;/p&gt;&lt;p&gt;For CI, this would cause an infinite number of builds, so they added a feature where if you include &amp;quot;***NO_CI***&amp;quot; as a comment on your check-in, that check-in isn&amp;#39;t considered when determining whether to trigger a build.&lt;/p&gt;&lt;p&gt;While having builds happen every night regardless of whether anything changed obviously isn&amp;#39;t a serious of an issue as infinitely triggering builds, but this problem makes the &amp;quot;Build even if nothing has changed&amp;quot; useless - cluttering up your universe of &amp;quot;Builds&amp;quot; with unneeded ones.&amp;nbsp; This could especially be an issue for Shops with lots of small applications that don&amp;#39;t have a lot of development activity against them.&lt;/p&gt;&lt;p&gt;Of course - this is an argument for just turning on CI....&lt;/p&gt;&lt;p&gt;I reported this bug to Microsoft &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=339882" target="_blank"&gt;here&lt;/a&gt;.&amp;nbsp; Forum post where Microsoft acknowledged it IS a bug is &lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3230750&amp;amp;SiteID=1" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=3749" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author><category term="TFS" scheme="http://blog.magenic.com/blogs/daniels/archive/tags/TFS/default.aspx" /></entry><entry><title>Another Build Glitch</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/02/15/Another-Build-Glitch.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/02/15/Another-Build-Glitch.aspx</id><published>2008-02-15T19:15:00Z</published><updated>2008-02-15T19:15:00Z</updated><content type="html">&lt;p&gt;So here I am cruising along on my TFS Implementation.&amp;nbsp; Got the code into version control redoing the File References in a way that will end the misery we&amp;#39;re living with on the old system and ready to start building the Application.&amp;nbsp; Instead of one big solution, I&amp;#39;m breaking the Application into it&amp;#39;s &amp;quot;Deployable Components&amp;quot;.&amp;nbsp; For this app, they have two Web Services Projects, a Web application, a DLL for Notification Services, a Console Application and a Click-Once Deployed Windows Form Application.&amp;nbsp; So I created six solutions instead of the one.&amp;nbsp; I create my build types and build.&lt;/p&gt;&lt;p&gt;&amp;nbsp;I start with one of the Web Services and the web application.&amp;nbsp; I get my DLL&amp;#39;s built quite nicely, but there&amp;#39;s no _PublishedWebSites folder in my binaries tree (let alone on the drop site).&amp;nbsp; I try to dig in and see what&amp;#39;s wrong with my build type definition.&amp;nbsp; Can&amp;#39;t find anything.&amp;nbsp; I first try Googleing on &amp;quot;How to build Web Applications in TFS&amp;quot; and just about EVERYTHING refers me to a page on MSDN that no longer exists (gotta love that).&amp;nbsp; I keep digging and I&amp;#39;m SURE I&amp;#39;m doing everything correctly.&lt;/p&gt;&lt;p&gt;So I get frustrated and post the problem to the MSDN Forum.&amp;nbsp; That helps me focus - and I decide the next step is to build a &amp;quot;Hello World&amp;quot; application.&amp;nbsp; I build a Web Application with a single page that says &amp;quot;Hello World&amp;quot; and an &amp;lt;ASP:Label&amp;gt; where I pass in the date.&amp;nbsp; Add it to Source Control, setup a build type, build it, and yup - I get the proverbial _PublishedWebsites folder nicely organized to deploy to a server.&lt;/p&gt;&lt;p&gt;Then I did some more Googleing and ran across &lt;a href="http://blog.donnfelker.com/2008/01/08/TFSBuildNotPublishingWebApplications.aspx" title="this blog post" target="_blank"&gt;This blog post&lt;/a&gt;&amp;nbsp;from Donn Felker, which I had scanned past and initially didn&amp;#39;t realize was my problem. &amp;nbsp;So I open up the .csproj for Hello World - and yup there is a line in there for the &lt;em&gt;Microsoft.WebApplication.targets.&amp;nbsp; &lt;/em&gt;I then opened up the csproj for the application I&amp;#39;m migrating from VSS and unlike Don&amp;#39;s where the line was commented out, in my projects, it was missing entirely.&lt;/p&gt;&lt;p&gt;So I edited the file, inserted the lines - and presto - I get a _publilshedWebsites folder!&lt;/p&gt;&lt;p&gt;So&amp;nbsp;thanks Donn for&amp;nbsp;blogging about your solution - saved me some serious time!&amp;nbsp;&lt;/p&gt;&lt;p&gt;Now to move on to ClickOnce publishing....&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=2110" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry><entry><title>Keep those Versions Straight!</title><link rel="alternate" type="text/html" href="http://blog.magenic.com/blogs/daniels/archive/2008/02/07/Keep-those-Versions-Straight_2100_.aspx" /><id>http://blog.magenic.com/blogs/daniels/archive/2008/02/07/Keep-those-Versions-Straight_2100_.aspx</id><published>2008-02-07T21:52:00Z</published><updated>2008-02-07T21:52:00Z</updated><content type="html">&lt;p&gt;I had been pulled away from the TFS project for a week to help out on another and finally was able to get back to TFS.&amp;nbsp; My client has a Framework they wrote that is a mix of CSLA, Microsoft Enterprise Library and custom code.&amp;nbsp; I have that building successfully so I had moved on to the Application itself.&amp;nbsp; I made some extensive changes to how the referenced DLL&amp;#39;s work (including the aforementioned Framework) - so I did that all manually after removing the bindings to source safe.&lt;/p&gt;&lt;p&gt;&amp;nbsp;So I go ahead and add the solution to TFS Source Control and create a build type and BOOM I get a very bizarre error:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;span id="_ctl0_MainContent_PostFlatView"&gt;&lt;span&gt;Target &amp;quot;CoreCompileSolution&amp;quot; in file &amp;quot;C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets&amp;quot; from project &amp;quot;c:\TFSBuild\5\BuildType\TFSBuild.proj&amp;quot;:&lt;br /&gt;Using &amp;quot;WriteLinesToFile&amp;quot; task from assembly &amp;quot;Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot;.&lt;br /&gt;Task &amp;quot;WriteLinesToFile&amp;quot;&lt;br /&gt;C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(978,5): error MSB3491: Could not write lines to file &amp;quot;c:\TFSBuild\5\Sources\Steriworks\Main\Source\SteriWorks.sln.Debug.vsprops&amp;quot;. Could not find a part of the path &amp;#39;c:\TFSBuild\5\Sources\Steriworks\Main\Source\SteriWorks.sln.Debug.vsprops&amp;#39;.&lt;br /&gt;Done executing task &amp;quot;WriteLinesToFile&amp;quot; -- FAILED.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;Googleing the problem brought me to &lt;a href="http://sstjean.blogspot.com/2006/06/insidious-link-between-tfs-version.html" title="this blog post" target="_blank"&gt;this blog post&lt;/a&gt;&amp;nbsp;by our friendly neighborhood Magenic TFS guru Steve St Jean: which explained the error - but a symptom caused by&amp;nbsp; different reason.&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;What&amp;#39;s going on here is that the Build was trying to create a vsprops file in the solution directory - but this directory is read-only (needless to say - coming straight from the Source Control) so it &amp;quot;blowed up real good&amp;quot;.&amp;nbsp; But the question was why?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;Digging into the &amp;quot;C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(978,5): &amp;quot; was even stranger.&amp;nbsp; Here it is:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;span id="_ctl0_MainContent_PostFlatView"&gt;&lt;span&gt;&amp;lt;!-- Generate the VCOverride file for C++ projects --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WriteLinesToFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File=&amp;quot;$(VsPropsFile)&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lines=&amp;quot;$(VCOverridesOpen) OutputDirectory=%22$(OutDir)%22%3E%0D%0A$(VCOverridesCodeAnalysis)$(AdditionalVCOverrides)$(VCOverridesClose)&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Overwrite=&amp;quot;true&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Well, my project isn&amp;#39;t a C++ project and furthermore the variable there refers to Code Analysis which I&amp;#39;m not using (at the moment at least).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;So I decide to branch the code (Ah such TFS goodness - that&amp;#39;s something always to be avoided in VSS), start whacking parts of the Solution to find out what&amp;#39;s causing it.&amp;nbsp; I start to do that and then go to create a new build type when I realize:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;I had created the build type in Visual Studio 2005!&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;My client is still using VSTS2005 for their development.&amp;nbsp; Several of the developers are still on Windows 2000 (they skipped XP and are migrating from Win2K to Vista) and haven&amp;#39;t decided when they want to take the plunge to 2008.&amp;nbsp; But since we started the TFS project after Team System 2008 was RTM we decided to use the 2008 Version of TFS.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;So when I am working on the source code in Visual Studio - I need to use VS2005 - but when I do some customization for TFS - I need to use 2008.&amp;nbsp; However the Icons are the same - (I changed on my desktop - but on the Task bar - they are the same) - so it can be tricky keeping which one is straight.&amp;nbsp; I knew that you couldn&amp;#39;t&amp;nbsp;&amp;quot;queue&amp;quot; a TFS2008 build from VS2005 - and I never &lt;strong&gt;intended&lt;/strong&gt; to create the build type in VS2005 - but I did&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Obviously, this is another incomparability between 2005 and 2008 as far as creating Build Types are concerned.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;So I deleted the Build Type, recreated in Visual Studio 2008 and presto!&amp;nbsp; The error went away!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Now to get the build to work!&amp;nbsp; (It&amp;#39;s broken - but at least it&amp;#39;s errors I expect to get at this point in the process)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;What&amp;#39;s going on here is that the Build was trying to create a vsprops file in the solution directory - but this directory is read-only (needless to say - coming straight from the Source Control) so it &amp;quot;blowed up real good&amp;quot;.&amp;nbsp; But the question was why?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;Digging into the &amp;quot;C:\Program Files\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(978,5): &amp;quot; was even stranger.&amp;nbsp; Here it is:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp;&lt;span id="_ctl0_MainContent_PostFlatView"&gt;&lt;span&gt;&amp;lt;!-- Generate the VCOverride file for C++ projects --&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;WriteLinesToFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File=&amp;quot;$(VsPropsFile)&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lines=&amp;quot;$(VCOverridesOpen) OutputDirectory=%22$(OutDir)%22%3E%0D%0A$(VCOverridesCodeAnalysis)$(AdditionalVCOverrides)$(VCOverridesClose)&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Overwrite=&amp;quot;true&amp;quot; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Well, my project isn&amp;#39;t a C++ project and furthermore the variable there refers to Code Analysis which I&amp;#39;m not using (at the moment at least).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;So I decide to branch the code (Ah such TFS goodness - that&amp;#39;s something always to be avoided in VSS), start whacking parts of the Solution to find out what&amp;#39;s causing it.&amp;nbsp; I start to do that and then go to create a new build type when I realize:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;strong&gt;I had created the build type in Visual Studio 2005!&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;My client is still using VSTS2005 for their development.&amp;nbsp; Several of the developers are still on Windows 2000 (they skipped XP and are migrating from Win2K to Vista) and haven&amp;#39;t decided when they want to take the plunge to 2008.&amp;nbsp; But since we started the TFS project after Team System 2008 was RTM we decided to use the 2008 Version of TFS.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;So when I am working on the source code in Visual Studio - I need to use VS2005 - but when I do some customization for TFS - I need to use 2008.&amp;nbsp; However the Icons are the same - (I changed on my desktop - but on the Task bar - they are the same) - so it can be tricky keeping which one is straight.&amp;nbsp; I knew that you couldn&amp;#39;t&amp;nbsp;&amp;quot;queue&amp;quot; a TFS2008 build from VS2005 - and I never &lt;strong&gt;intended&lt;/strong&gt; to create the build type in VS2005 - but I did&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Obviously, this is another incomparability between 2005 and 2008 as far as creating Build Types are concerned.&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;So I deleted the Build Type, recreated in Visual Studio 2008 and presto!&amp;nbsp; The error went away!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Now to get the build to work!&amp;nbsp; (It&amp;#39;s broken - but at least it&amp;#39;s errors I expect to get at this point in the process)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blog.magenic.com/aggbug.aspx?PostID=1996" width="1" height="1"&gt;</content><author><name>DanielS</name><uri>http://blog.magenic.com/members/DanielS.aspx</uri></author></entry></feed>