Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly

I recently created an MVC 5 app in VS 2015 and tried to build it with VSTS. It failed every time even though it built fine i VS 2015. It appears the issue is the NuGet packages that are stored in VSTS. I deleted the packages directory and rebuilt the solution with VSTS and everything worked fine. I am not sure why it fails this time compared to all other times i have created a solution with a packages directory in VSTS, but i will need to dig in and find the answer.

Here is the actual error I get.

The “Microsoft.CodeAnalysis.BuildTasks.Csc” task could not be
loaded from the assembly …\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly ‘file:///…\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll’ or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

MSBuild vs VSBuild steps in VSTS

So i demo the new VSTS build features and one question i get a lot is “What’s the difference between MSBuild and the Visual Studio Build steps?” so I am going to list out some reasons for using one or the other.

MSBuild

Lets say you dont want to build an .sln file to build but rather the .proj files. Then this is the option could use. It also does not require Visual Studio to be deployed on the build server.

If you want to build multiple projects, specify search criteria. You can use a single-folder wildcard (*) and recursive wildcards (**). For example, **\*.*proj searches for all MSBuild project (.*proj) files in all subdirectories.

Make the sure the projects you specify are downloaded by this build definition. On the Repository tab:

  • If you use TFVC, make sure that the project is a child of one of the mappings on the Repository tab.
  • If you use Git, make sure that the project or project is in your Git repo, in a branch that you’re building.

VSBuild

If you are building a solution, in most cases you should use the Visual Studio Build step. This step automatically:

  • Sets the /p:VisualStudioVersion property for you. This forces MSBuild to use a particular set of targets that increase the likelihood of a successful build.

  • Specifies the MSBuild version argument.

Information about how to implement the steps are here in the MSDN library.

Export Azure ARM templates

So i just stumbled across this feature in Azure. Its the ability to export templates of resource groups. This is wicked cool. I could have used this months ago. What i like (there is a lot to like) is that I can use it as a great teaching tool. If i am looking to automate my deployments and I get stuck on a particular item, i can easily create it in the UI then export the template to see how i would code it up. Its really easy to do. Just go into the Azure portal and select a Resource Group you want to export.In the settings you will find the “Export Template” option.

image

Click on it and it will produce the the template with some options to download, save, or even redeploy it. This is what i need so I am going to download it locally and start to work on it.. You also have the option of clicking through the resources, parameters, and variables. Not only does it show you the resources, but you also have the option to view the Powershell or CLI code.I also like the fact that it gives me the parameters file i can use and build off of.

image

I have been waiting for this functionality for a while now and its nice that the team has released it finally. I will definitely using this feature in the future.

CatLight Build notification tool

I have been doing a series of webcasts on YouTube around TFS/VSTS Build. i was approached by the folks at CatLight to demo that in the videos i do. I decided to look at the tool and write aa post first.Its a free download and easy setup to get it running. It sits in the tray and turns colors based on a build. Red means there is a failed build on one of your projects, amber is a partial completion. Just the cat outline mean your good. Click on the cat icon in the tray opens the Dashboard where you can configure what projects you want to monitor as well as the current status of the builds for each project. Click on the build name in the Dashboard and i takes you to that build summary. I can see the usefulness in the tool, as a visual way to stay on top of builds. Of course there are other ways to do it also. If this sounds interesting go to http://catlight.io and check it out.

VSTS Sample Data Widget

I do a lot of demos and code camps where I show off VSTS. The one thing i have to do is get sample data ready to go so I can demo well, I was reading about some VSTS extensions in the Marketplace when i came across a new extension that allows users to create sample data in a team project. I see its in preview and was just put out a few days ago. If you are not familiar with the Marketplace, its a place that the community can publish extensions for VSTS and TFS.

Its easy to install and setup the Sample Data widget. Go to the marketplace and install the widget first.

https://marketplace.visualstudio.com/items?itemName=ms-devlabs.SampleDataWidget

Once installed go into VSTS and select a team project that you nee to create sample data for. Go to the Home page of the team project and in the bottom right corner, you will see a round blue circle with a pencil in it. Clicking on that brings up a green circle with a plus in it. This one allows you to add widgets to the Home page to customize as you need. Click it and when the widget selection dialog comes up scroll down until you find the Sample Data widget and select it. Click the Add button on the dialog and when it goes away you just click the blue circle with a checkmark in it and you’re all set. The widget should be added to the bottom of the home page. When you find it, enter the name of the team project you want to add data to and click on Create. It will start creating test data for you. In my case it gave me an error the first time, so i clicked Delete to clean up the sample data  and tried again. It failed again, but when i checked to see if there was any data created there was. I looked through it and there does not appear to be any issues with the data so i am going with it. I guess I’ll go back to the Marketplace and leave the team a message that i have some issues with it and i am sure they will look at that at some point. You have to remember that its in Preview so no worries.I will work through some demos and see how it goes. So if you need sample data for any reason in VSTS, check it out.

TFS Build 2015 Video Series

TFS Build 2015 Video Series

I have been working with customers lately that are using the new build system in TFS 2015. I get a lot of questions around the basics. So I decided to do a series of videos on You Tube walking through the TFS/VSTS Build. They are starting off doing basic stuff but as we progress I will get into some more advanced topics. Please check it out and subscribe to stay updated as new videos drop. I am hoping to do a couple every week at this point. I created a TFS Build 2015 Playlist. Here is the link to get you there.

https://www.youtube.com/playlist?list=PL5FylblNKuTRwFBBiT0srlz9caDL8OO3i

-paul

So Flo Code Camp Wrap up

I want to thank everyone that came out and seen me speak today at the South Florida Code Camp 2016. I had a great time and great dialogs during my sessions. As promised I am posting my slide decks here. I will have the videos up by Monday on One Drive , but in the mean time here are the slides.

https://onedrive.live.com/?id=92A244250FE6C385%21247645&cid=92A244250FE6C385

Azure Resource Manager Template Visualizer

Azure Resource Manager Template Visualizer

Lately I have been doing a lot of work in Azure with the new Azure Resource Manager (ARM) templates. I have really come to like it, especially the fact that can create a Visual Studio 2015 project and build and deploy from that project. Makes it really easy to work with. Now that I have quite a few of these templates, i found it would be nice to see how the different resources in the template are related to each other. Like how are the Nics related to the VMs. If you have not yet used the ARM templates I suggest that you take a look at them if you are building out an Azure environment. So back to templates. I recently found a template visualizer. This is an awesome tool. It allows me to see the relationship between different parts of my Azure deployment. Its called the Azure Resource Manager Template Visualizer. I will explain here a little about the tool. First off it allows you to import your existing templates and immediately visualizes it.

Template visualizer
img

This makes it really easy to see the relationships. It also allow you to create and or remove relationships. It also has a toolbox so that you can add different items to the template.

Toolbox
img1

As you can see you can do quite a bit with the tool. What i like is that its all web based so that I can create templates and then run them later. You do need to download the templates to run them in Powershell, so there is no deploy functionality like there is in Visual Studio. There are a few options of what you can do with the tool.

Tool Options
img2

Like i stated you can open an existing template, or create and download a new one. You also have the option to manage your parameters passed into the template. For example maybe you have virtual machine names that change per environment that you deploy to. So Dev would use one set and QA would use another set of parameters. Using parameter allows you to use one template for all environments so you can generate repeatable matching environments every time you deploy, which is the goal after all.I like that feature since its easier to manage parameters here rather than in Visual Studio.

Next there is the ARM quick start templates. These are a large set of ARM templates available on GitHub that do very specific things in ARM. I used them to figure out how to setup disk encryption, creating Linux VMs, setting up networks, etc. I really encourage you to look at these if you are just starting out, or if you are having difficulties trying to setup a certain resource.

quickstart loader
img3

As you can see there is almost every type of resource you would want to create. So if you are already using or thinking about using ARM then i suggest that you take a look at the visualizer to assit you in your template development.

TFS Cross Platform Build agent setup

One of the great things about TFS 2015 Build is the fact that I can run  OSx builds. Now you do need a mac to run the agent on obviously but once setup it works great. I struggled a bit getting everything setup so i decided to write about it in case others run into issues. Hopefully this will save you some time.

There are a few things you need to download to get it setup.

  1. Download and run node – https://www.npmjs.com/package/vsoagent-installer
  2. Download and run Java SDK (runtime is not sufficient) – http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  3. Download the Team Explorer Everywhere Command Line Client (TEE CLC) – https://www.microsoft.com/en-us/download/details.aspx?id=47727

That gets you to a point where you can start to configure the Mac.

  1. Open a Terminal window  and run the following command:

Install the agent installer

sudo npm install vsoagent-installer -g
sudo chown -R $USER ~/.npm

Create the agent

mkdir myagent; cd myagent

vsoagent-installer

Now you need to update the Path in OS X.

cd ~/ – Takes you to the root
open .profile – opens the profile file in a text editor

In the file enter the following line PATH=/Users/username/path to the tf/:$PATH. So mine looks like so
“PATH=/Users/Myusername/Downloads/myagent/TEE-CLC-14.0.1/:$PATH

Close the Terminal window and open new session. Run tf and see if you get results. If you don’t there is an issue with the path in the file

NOTE – Do not use quotes in the path you enter in the file. I did and it would not work. Took me a bit to figure that out.

 

You will be asked to enter the alternative credentials for TFS. If you need to set these up here are the steps: (I am using VSO)

Navigate to Visual Studio Online

Click the “gear” icon in the top right corner. This will launch VSO admin page

Click on your username in the top right corner. There should be a dropdown. Select the “My Profile”  item.

Once on the Profile page, click the “Security” link on the upper left side

There should be an option “Alternate Authentication Credentials” Enter the new credentials you will use.

Here is a link that explains it also – https://www.visualstudio.com/en-us/integrate/get-started/auth/overview

Now you need to create an agent pool in VSO. On the VSO admin page in the upper left corner click the Control Panel link. Click on the Agent Pools tab and create a new Pool. You will need this when you configure the agent.

Configure on First Run

node agent/vsoagent

Now you have two options for running the Agent.

  1. Run interactively – For testing purposes
    node agent/vsoagent
  2. Run as a Service – Survives reboots. Use in Production
    ./agent/svc.sh install agent

Thats pretty much it. Now go into VSO admin page and click on the Control Panel link again. Click on the Agent Pools tab and select your pool you created. You should see an agent that you created and a green bar on the left side of the agent name. That indicates it is connected and good to go. Next you need to create an OSX build in VSO. I will write another post to explain that.

Hope this saves you some time and effort. If there is anything i missed here please let me know.

Release Management 2015 and TFS Build 2015 Setup

If you have not checked out the new build features in TFS 2015 then you really need to look into it. I have been using it now for a couple months and I must say its really nice to work with and so much better than Windows Workflow. But that’s for another post. here I want to explain the process for setting up and deploying with Release Management 2015 from TFS Build 2015. Currently there is no build task built into TFS that allows you to deploy with RM so I am using the task that Daniel Mann created.

I am going on the assumption you have setup a build pool and agent and are ready to run a build, or already have a build. Also be aware that the RM client needs to be installed on the build server for the task to work correctly.

First thing we need to do is to download the TFS Build Extensions Command Line Utility and install it. The documentation on the site works well so just follow it.  If you run the command npm install -g tfx-cli and you get an error “npm is not recognized…” then you need need to download and run the Node.js msi file. Now rerun the command to install the tfx-cli. Once you have that installed, you need to download and extract theInCycle Build Tasks.

Once you have the completed the install run the following command to verify the install worked – tfx help This should present you with the command options.

You need to be in the top level Agent Pool Administrators group to manipulate tasks See here. Follow the steps to get the user added to the group. I also had to do one other thing that was not documented anywhere. I needed to set IIS to use basic authentication. Open the Server Manager and select the Manage > Add Roles and Features

image

When the dialog launches, go through until you get to the Roles screen. Now locate the Web Server (IIS) (Installed). Expand the section , locate the Security (Installed) and expand it. Check the BasicAuthentication checkbox.

image

Click next

Click Next again and then click Install. Once complete close the dialog window.

Now you need to set the tfs virtual directory to use basic authentication. To do so open the IIS Manager and expand the Team Foundation Server site. Click on the tfs virtual directory and then select the center window to Features View (tabs at bottom of window). Locate the IIS section and double click on the  Authentication item.

image

Now select the Basic Authentication Item. On the right side of the screen select the Enable link.

image

Now that we have that all set we need to login and upload the Incycle Build Task “RM Agent Release” to do so run the login command.

Open a command prompt and run tfx login –authType basic (make sure its lower case “basic”) – You need to use the authtype option if you are working with an on-premises TFS environment. Enter in the tfs collection you will be using, then your username and password.

image

Now that you are logged in, you need to upload the “RM Agent Release” task. In a command window enter tfx build tasks upload –taskpath <path to RM Agent Release directory>

image

Verify the task has been uploaded by running the tfx build tasks list command.

image

Scroll down the list until you see the following entry.

image

I am using the Tailspin Toys project so I have something to build. Now in reality I would have configured RM 2015 to do a complete deployment, but for this post I just want to show you how to fire off RM from TFS 2015 Build.

Now its time to create a build. Launch the TFS web portal and navigate to your project’s home screen.  Now click on the Build link

Once on the Build screen, click the green plus sign to create a new build definition. Select the Visual Studio template. and click OK. If you do not have a solution to build, just select the Empty definition.

image

Now you need to add a build step. Select the Add build step… option.

The task is under the Deploy section. Select the Start Agent-Based Release. Click Add and then close the dialog window.

image

Set up the build by selecting a solution to build and Save the build.

image

Now queue a new build. Watch the console as it runs and wait for RM to kick off.