Swallow GIT output in PowerShell run by Team Foundation Server because it’s STDERR which breaks the build

Imagine you want to commit and push a changed file during a build. Grant the user “Project Collection Build Service (DefaultCollection)” the following permissions on the repository:ContributeReadEnable the option “Allow scripts to access OAuth token” on the build.Set the variable “system.prefergit” to “true” on the build.Add a PowerShell-task to the buildRun… The issue is that either a) GIT has no idea what STDERR is and writes success messages to the error streamorb) TFS Build interprets the output of GIT wrong and fails the build even if the exit code is 0. Fun fact: It works with the “Command Line”-Task without any issues.Both out of my control – maybe another Issue/PR on the GIT project could solve it as it is open source, But I need a solution NOW! So here is how to modify the script: HTH

Builds with conditional NuGet publishing in Team Foundation Server

For a nightly build it makes no sense to publish a NuGet package as no code changed and therefore the same GitVersion is calculated.Since version 2017 Update 3 the on premise version of Microsoft's Team Foundation Server supports "Custom Conditions" on "Build Tasks" – but sadly not on "Task Groups".Here is what you need to exclude a step from a scheduled build: Here a screenshot of the condition in action:HTH

Using the Windows Credential Manager from MsBuild

Today I needed to make a web service call with authentication from MsBuild. Of course storing the credentials in plain text is not an option.The Windows Credential Manager User Interface can be opened by running the command:control /name Microsoft.CredentialManagerThere is also a command line interface:cmdkey.exeAs the Windows APIs are not provided as wrapper through the BCL a NuGet package comes to help:nuget.exe install CredentialManagementFinally everything wrapped up in a MsBuild Task:

Make a WebApplication project automatically publish on build

If you want to publish a Web Application project you can call MsBuild with parameters. Having a publish happen on each and every build - there is work to do. Visual Studio project files are MsBuild files since Version 2005. There is a way to force MsBuild and Visual Studio behave as requested. The project file needs to be edited slightly: <PropertyGroup> <PublishDestination>..\..\..\out\YourPublishDirectory</PublishDestination> </PropertyGroup> <Target Name="PublishToFileSystem" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder" AfterTargets="Build"> <MakeDir Condition="!Exists($(PublishDestination))" Directories="$(PublishDestination)" /> <ItemGroup> <PublishFiles Include="$(_PackageTempDir)\**\*.*" /> </ItemGroup> <Copy SourceFiles="@(PublishFiles)" DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="True" /> </Target>

Updating the .NET target framework for many projects

I do component based development. Meaning I have 30+ repos, builds and each of them has 1-10 projects – The main library project, tests, samples and so on. The news about the support end for the .NET Framework 4, 4.5 and 4.5.1 was the motivation to update ALL of my projects. I know this is not neccessary because… .NET 4.5.2, 4.6 and 4.6.1 are compatible, in-place updates on top of .NET 4, .NET 4.5, and .NET 4.5.1. This means that applications built to target any of these previous .NET 4.x versions will continue running on .NET 4.5.2 without change. No recompiling of apps is necessary. ... but I wanted to update them from version 4 to since a long time now. To do the job I wrote a small powershell script. Beside the path command set-frameworkVersion there is CommitAndPush-GitRepositories which commits and pushes all repositories found underneath the path variable.

.NET Framework 4.6 Release

The new framework version is out. As with every new release it seems to me that the search indexes on Microsoft downloads have not been rebuilt yet. So I abuse this blog post and note the download links to myself…Microsoft .NET Framework 4.6 (Offline Installer) for Windows Vista SP2, Windows 7 SP1, Windows 8, Windows 8.1, Windows Server 2008 SP2 Windows Server 2008 R2 SP1, Windows Server 2012 and Windows Server 2012 R2 Microsoft Build Tools 2015Windows 10 and .NET Framework 4.6 SDKIntelliTrace Collector for Visual Studio 2015 (Just replace the Version number in the Installation Path)

Enable or disable FxCop Code Analysis solution wide in Visual Studio Package Manager Console

I really like FxCop. But in a debugging session it can be useful to save time by temporarily disabling the code analysis. Sadly there is no *global switch* to turn it off and on again. So here is my approach: Create a new text file in the directory "C:\Users\{your user}\Documents\WindowsPowerShell" named "NuGet_profile.ps1" and add the following code: Restart Visual Studio. Click the menu "View" | "Other Windows" | "Package Manager Console". Now you can execute the following commands: > Enable-CodeAnalysis > Disable-CodeAnalysis