brandonmartinez

Utilize Microsoft.TeamFoundation PowerShell Modules in VSO/VSTS Custom Tasks

If you haven’t been paying attention to the “New Microsoft”, you may have missed that a lot of their new code is ending up on places like Github. Included in that is the backbone of their new Visual Studio Team Services build and deploy services: tasks.

In exploring the Github repository, I noticed that they were making use of some interesting, non-public modules (primarily in the Microsoft.TeamFoundation.DistributedTask.* namespace). Several of their scripts referenced code like this:

# Import the Task.Common and Task.Internal dll that has all the cmdlets we need for Build
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
Import-Module "Microsoft.TeamFoundation.DistributedTask.Task.Common"

In attempting to create my own tasks, I found that I couldn’t do that same import. Errors like this would prevent me from utilizing them:

##[error]import-module : Could not load file or assembly 'Microsoft.TeamFoundation.DistributedTask.Agent.Interfaces,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
At C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools
\agents\default\tasks\
BuildDnxWebApp\0.1.11\Build-DnxWebApp.ps1:24 char:1
+ import-module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,
+ Microsoft.PowerShell.Commands.ImportModuleCommand

After much investigation, I found where the modules live on the VSO/VSTS server. Change your import line to directly reference the agent’s module path:

# Import the Task.Common and Task.Internal dll that has all the cmdlets we need for Build
$agentWorkerModulesPath = "$($env:AGENT_HOMEDIRECTORY)\agent\worker\Modules"
$agentDistributedTaskInternalModulePath = "$agentWorkerModulesPath\Microsoft.TeamFoundation.DistributedTask.Task.Internal\Microsoft.TeamFoundation.DistributedTask.Task.Internal.dll"
$agentDistributedTaskCommonModulePath = "$agentWorkerModulesPath\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.dll"
  
Write-Host "Importing VSTS Module $agentDistributedTaskInternalModulePath" 
Import-Module $agentDistributedTaskInternalModulePath
Write-Host "Importing VSTS Module $agentDistributedTaskCommonModulePath"
Import-Module $agentDistributedTaskCommonModulePath

The vital part is the $env:AGENT_HOMEDIRECTORY. This is a predefined variable available to the build runner pointing to the agent’s home directory. Underneath this is where the tasks, modules, and other agent-specific assets live. After prefixing the modules with the proper path, I was back in business!

Hopefully this helps someone; I couldn’t find a single piece of info on this. Good luck!

Migration Notes: ASP.NET 5 MVC 6 – Beta 8 to RC 1

I finally had a chance to get our codebase to the release candidate of ASP.NET 5. Excited to have a supported release available and more-or-less production-ready! As usual, here are my personal release notes to my team on the upgrade process.

Good Afternoon, Everyone:

The upgrade to release candidate 1 (update 1) has been completed. As with previous beta updates, Visual Studio requires updated tooling; this time it’s in the form of Visual Studio 2015 Update 1 (download) (release notes).

And don’t forget to update your dnvm stuff from the command line: dnvm upgrade

You may want to remove all other betas from your user folder: C:\Users\{YOUR PROFILE}\.dnx\runtimes

The following announcements/issues were relevant to our codebase to some degree:

And just a couple to take note of:

Some additional references:

Re-Enable WebSocket Support in SignalR 3 Beta 8

If you’ve recently upgraded to the latest ASP.NET 5 Beta 8 Packages, you may have noticed SignalR will no longer use WebSockets and default back to long polling. Due to some changes in how the web server stack is handled, mainly through IIS or IIS Express, you now have to adjust your middleware pipeline to add websocket support. Continue reading…

Migration Notes: ASP.NET 5 MVC 6 – Beta 7 to Beta 8

Time for the last beta of ASP.NET 5 MVC 6! Here are my release notes to my current team on migrating from Beta 7 to Beta 8:

Good Morning, Everyone:

The upgrade to beta 8 has been completed. As with previous beta updates, Visual Studio requires updated tooling, so please grab these:

  • DotNetVersionManager-x64.msi
  • WebToolsExtensionsVS14

From here: http://www.microsoft.com/en-us/download/details.aspx?id=49442

And don’t forget to update your dnvm stuff (ORDER MATTERS):

  • dnvm upgrade -arch x64 -r clr
  • dnvm upgrade -arch x86 -r clr

You may want to remove all other betas from your user folder: C:\Users\{YOUR PROFILE}\.dnx\runtimes

The following announcements/issues were relevant to our codebase to some degree:

A few interesting code changes:

ConfigurationBuilder Changes:

ConfigurationBuilder no longer takes the ApplicationBasePath; it is now fluently added.

var configBuilder = new ConfigurationBuilder()
   .SetBasePath(appEnv.ApplicationBasePath)
   .AddJsonFile("config.json")
   .AddEnvironmentVariables();

Web.config Changes:

Relying only on the new HttpHandler.

<handlers>
      <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
    </handlers>

I have not merged this to dev yet; I want to do some additional testing and will collaborate with you before I do. From forums and other posts, it looks like there may be some deployment and/or Azure issues from this release that need to be worked through.

Some additional references:

Deploy ASP.NET DNX WebJob to Azure

Over the past few weeks, I’ve really been digging into the Visual Studio Online Preview Build System. This has mostly been around deploying ASP.NET DNX web applications, and the last few blog posts have been around that process. Well, something new came up this past week: how do I deploy an ASP.NET DNX command line project as an Azure WebJob? Continue reading…

Deploying ASP.NET 5 Beta 7 Through Visual Studio Online

If you’re trying to deploy your ASP.NET 5 beta 7 application, you may be running into this error: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DNX.PackageManager' or one of its dependencies. The system cannot find the file specified.

The reason for that is the version of Visual Studio 2015 in the hosted build controller doesn’t have the latest set of web tools installed. The only way around this, besides hosting your own build controller, is to drop back to dnu build and dnu publish. Continue reading…

Using SignalR Past ASP.NET 5 Beta 5

If you’ve been using SignalR in the ASP.NET 5 betas, you may have noticed that after beta 5 you no longer can pull the NuGet package from the main repository. This is because SignalR has been put on hold until more of the ASP.NET 5 stack is complete. And while the ASP.NET team has said they’ll keep it up-to-date enough to bring in to the later betas, there’s a trick to actually getting that working. Continue reading…

Page 1 of 3112345...102030...»
Copyright © 2006 – 2016, Brandon Martinez. All rights reserved. A Martinez Media site.