TFS Team Build 2010 - queue build as a named user - tfs

After much messing around I've got CI implemented onto our test server. A custom workflow template builds and deploys 2 web apps (different servers), a database and a windows service. This is brill and takes all the worry out of deploying a test app.
I want to move this over to staging and live (queued manually), but doing it like this the TFS service account would need permissions on IIS for the web apps, DBOwner on the database and local admin on the service box. This is a big no-no for our tech guys!
What we could do is just give these permissions before we run the build and remove afterwards, but this means maintaining a list of what permissions to change where - ruining the convenience of one-click deployment a bit.
Ideally we'd just get the build to run using the account of the tech services guy whos got admin network-wide, is there a way to do that?

Yes you can do that via the TFS Administrator Console.
If you haven't configured your build machine, then you can choose the user during the configuration phase. You should see a Configuration Wizard page that allows you to choose a user account like this:
If your build machine is already configured, go to your build machine, then run %PROGRAMFILES%\Microsoft Team Foundation Server 2010\Tools\TfsMgmt.exe, then go to "Build Configuration", click at "Properties" link of the Build Service to open the Properties dialog, then click "stop to make changes" on the dialog, and you can change the account from the built-in account to a user one:

Related

The difference of uninstall the complete application and unconfigure TFS

We had moved everything from TFS sever to VSTS include database, logs. Not sure if we will use it again in the feature.
For now, we have two choices: uninstall the complete application/delete database entirely and simply unconfigure TFS
What are the differences between them? I want to choose the appropriate one.
To "Unconfigure TFS", please go to the Team Foundation Administration Console on the Application Tier machine. Click on the server name and click on "Remove Feature"
By Removing the feature, we will be removing
The Application Tier configuration from the server (but we don't
remove the binaries)
Connection with Data tier (but the databases won’t be deleted)
TFS Website.
TFS Application Pools
TFS Services (The Visual Studio Team Foundation Server Job Agent)
You can do the same from command prompt, execute TfsConfig setup /uninstall:ApplicationTier command to unconfigure TFS Application Tier. (You can also use various switches to remove other features SharePointExtensions, TeamBuild and VersionControlP
roxy) from server machine.
Usually we'd like to refresh the TFS Application Tier setup to defaults in case there's an unintended change in services/IIS settings and we want to set it back to defaults. We give an option to Remove Application Tier/Features without having to uninstall the complete application.
Another usage is when you are using pre-upgrade for test, you could quickly remove Application Tier. Since everything have been migrated, if you don't need the TFS server any more, just simply uninstall the complete application and database.You could back up your database, once you want to use again. Just install a new application and restore your database.

TFS Builds: Running the builds as administrator

We have one of our build projects that modifies the registry on the build machine (don't ask me why) and it needs to be done as administrator.
Is there some way to run msdev from the build agent as "administrator"?
We're using TFS 2012, soon to move to TFS 2013.
- Bruce
Add the build service account to the local Administrators group
Even though it's late - adding to Vian's answer, adding the account to the local Admin groups is probably the way to go here. Someone who is an Admin on the computer will have to do this.
In the start menu type in "User". It will come up as "Edit Local Users and Groups". Click on that.
In the window that just opened, Under Groups -> Administrators (double click to edit properties of Admin Group). Add the Build Machine Account.

Clean Windows Azure Website

My ASP.NET MVC project pushed to a Azure website with an extra DLL which is invalid. This is keeping the project from running correctly. If a new website is created it works perfectly. Cleaning the project locally and redeploying does not fix the problem. Is there a way to perform a "remote clean?"
This project is being deployed directly from Visual Studio with the publish menu item.
When you right click and click Publish Web on the left hand side there should be a settings tab. Click this. Then expand the option under File Publish Options and check the Box for Remove addtional files at destination. (This will wipe out whats already there)
Also can be detailed here: MSDN
Another trick to delete an entire Azure website deployment which can be done entirely in the Azure portal is:
1) Create a new empty deployment slot under the Azure website.
2) Swap it with the parent Azure website.
That will give you an empty Azure website. If you want you can delete the deployment slot afterwards.
You can also use console to delete any file. Kudu is a web tool that allow you to see inside of Azure web application.
Two ways to access Kudu
go here: https://yoursite.scm.azurewebsites.net/DebugConsole/?shell=powershell (replace with your real website name)
login to portal > app services > your site > Development tools > Advanced tools.
You can also delete files via Webmatrix (link in footer menu in Azure configuration portal)
Download the profile from Azure portal
Import publish profile in VS
Stop the web app in Azure portal
Stopping the web app ensures existing files including dlls and other resources will be deleted after publish succeeds.
This step might not be necessary, however, the existing web app could have some dlls that cannot be removed during publish directly, returning error messages like:
Web deployment task failed. (Unable to perform the operation ("Delete
File") for the specified directory ...
4. Publish with “Remove additional files at destination” checked
Start the web app again after publish succeeds.
for linux servers you dont get, CMD, then all you have to do its, Delete the deployment, then create deployment credentials for FTP and there you go with FTP client clean the wwwroot folder by your self.

How to have multiple custom publishing profiles for Azure webrole

Using the Azure publish wizard gives you some options for changing your config settings, but not enough. You can tell it which build configuration to use (which will apply a transform to your web config) but you only have 2 choices. Release and debug. Also you can specify which cloud service configuration to use which will transform your service.config but again only 2 choices Cloud and Local.
My problem is that I have 3 different versions of my application running in Azure. They are Dev, Demo, and Production. Each has their own database, storage accounts, and other settings related to authentication. Just having a release and debug transformation doesn't cut it.
Really what I would like is to have a script or something so that I could publish my app to each of my Azure instances. It would change my web.config and service.config and target the right azure instances.
Any suggestions are appreciated.
There used to be CodePlex project http://wappowershell.codeplex.com/, which now became an official tool here: https://www.windowsazure.com/en-us/manage/downloads/.
It's a set of Windows PowerShell cmdlets for managing Azure deployment.
Also the following question is pretty similar: Publish Azure Project from Command Line
In researching this I updated my Azure Tools to the October release. Not sure if these options were available in old release or not but here's what I ended up with.
As it turns out can add your own services configurations and build configurations in addition to the default ones (cloud/local/debug/release).
Services configurations can be added by:
Right click your Web role from your cloud service project and select properties.
At the top of the properties window open the Service Configuration menu. Then select manage.
Select a configuration and click the create copy button.
Select the copy and rename it to whatever you want.
Click close and now you should be able to have settings specific to your new service configuration.
Build configurations can be added by (I followed this blog post):
Select Build -> Configuration Manager from the menu. The
Configuration Manager dialog
Select from the Active solution configuration dropdown list to bring up the New Solution Configuration dialog.
Enter the name and select the configuration you want to copy. Click Ok.
Make sure you select the correct Configuration (release or debug) for each of your projects for your new solution configuration.
Notice there is still no web.config transform. To add a new Web.config transformation right-click on the Web.config file and from the menu select Add Config Transforms. Notice that a new configuration file matching your new configuration is automatically added
After following these steps I was able to create a new target profile in the Azure publishing wizard and select these configurations. This lets you automate your web.config settings using transforms and have your own custom cloud service configuration per publishing profile.
Here is another excellent reference that goes into much more detail then I was able to for this question.

How to move builds done via Build Manager on Team Foundation Server to another server?

So, we're using continuous integration in our current Team Foundation Server 2010 setup, and so far it's working great. We're doing shelvesets, the build is running on the Build Manager in TFS, and it's also running our MSTest unit tests for us.
My question is, and I can't seem to find any information on this, is how to move the "build unit" that is created by the Build Manager on TFS to another server?
Aka, how do I "promote" this build to our QA, staging, etc... environments?
Before, we've were using VS2010's Publish Web feature, which allows us to set up publish "profiles", and each profile can have a different web.config related to it. This is really useful for anything we keep in our config files, like db connection strings, paths to app servers, etc... changing automatically based on our Publish Profile. We choose the profile, build locally, then use the "Publish" button to move the entire app to another server.
This setup worked great for when there were two of us working, and we were using TFS for just its source repository, but now the builds are happening on the TFS server.
What I'm looking for is a way for when TFS does the build for us (it's no longer being done locally on our machine, but by TFS Build Manager) to:
take into account which "publish profile" to use. This will effect what web.config is used and other items you can associate with a profile in your IDE.
once the build is created, to find a way to "push" the build to one of our other servers (QA, Staging, production) FROM TFS.
I don't even know if that is possible or not. Maybe it's still a manual job to take the build created on TFS, and copy it over by hand, and unzip the project/files into the correct file path on the deployed server? Or maybe it's part of the workflow in TFS, and I still have yet to find it.
This is surely possible already from TFS. Read the posts from Vishal Joshi on this topic, starting with: http://vishaljoshi.blogspot.com/2011/07/documenting-key-end-to-end-deployment.html
The solution I came up with is I wrote my own build handler for TFS, and use that code to push builds to our different environments. Here is the link I used to help me: http://geekswithblogs.net/jakob/archive/2010/10/27/devleoping-and-debugging-server-side-event-handlers-in-tfs-2010.aspx.
If anyone wants more specifics, just contact me and I'll be glad to help you.

Resources