0
votes

Is it possible to use PowerShell to deploy from VSO and/or view the file system that VSO stores the code in?

Recently we have moved our source from a Local TFS to TFService / Visual Studio Online. On the Local TFS we had a PowerShell script that would deploy the application to Azure Blob.

This is the body of what the script did

1.Create a staging/temporary folder

2.Copy the bin directory after the build,

3.Create a txt file that pulled the version # from the AssemblyInfo.CS file on the build agent (which the customer application would check to see if it needs to update)

4.Create a .sql file that also pulled the version # from the AssemblyInfo.CS file (which updates the customers DB)

5.Zips the copied bin and the created .sql together

6.Uploads the Zip and the txt to Azure Blob

We want to continue to use this script to deploy with while on VSO but the current issue is that I'm running blind on the file paths. I reviewed the build log and found C:\a\src and C:\a\bin, which is a start. I've also been able to run simple commands such as dir/mkdir after the build without errors coming back which I'm assuming means I can manipulate the file system VSO uses to some degree at least.

I Have also posted this question on the msdn site @ http://social.msdn.microsoft.com/Forums/vstudio/en-US/4a951897-52b3-4ee9-91e3-e1412c242207/deploy-to-azure-storage-from-vso-with-powershell?forum=tfsgeneral

1

1 Answers

0
votes

Figured I'd update this with the solution to my issue.

VSO stores all the project files off the C:\a\ directory.

Source files are located in C:\a\src\

The bin directory is located at C:\a\bin\

In order to get to the correct files in your project, just follow the projects path as you see it in Visual Studio or on VSO.

Example:

Say I have a Project XYZ, which contains my BuildProcessTemplates and a directory named XYZ which holds my branches.

In order to get to the SRC of XYZ, my script would have to target 'C:\a\src\XYZ(projectName)\XYZ(directory)\Version0101(aBranch)\anotherDirectory\theFileIneed.txt'

You can manipulate the VSO directories as you see fit as you have all C.R.U.D. capabilities.

In my case, I create (or recreate) a STAGING folder

$prebuildSTAGING = "C:\a\PrebuildSTAGING"
function Set-Staging
{
    if(!(test-path $prebuildSTAGING))
    {
        mkdir $prebuildSTAGING -Force
    }
    else
    {
        rmdir $prebuildSTAGING -Recurse -Force
        mkdir $prebuildSTAGING -Force
    }
}

This will ensure that I have fresh STAGING folder every time. I then pick the file that I need, edit it to fit my requirements, then push it back into SRC.

Doing this has allowed me to Automate incrementing the Assembly Version of the application as well as deploy it to Azure without any big headaches along the way.

UPDATE:::

Just wanted to update this again in case anyone is actually packaging their app on VSTS in this fashion ---

The directories have changed ( multiple times now ). The correct path to access the built files is C:\a\1\s\ {YourProjectName}\bin\ {YourBuildPlatform}\ {YourBuildConfiguration}\

Ex: Solution Name in VS = ABC, Project Name in the solution = XYZ You have a configuration for XYZ that is named TEST with a Platform of x86

The path to the bin would be C:\a\1\s\XYZ\bin\x86\TEST