XenApp and App-V | Some Facts

Scenario – We have a App-V package and we have requirements to run some executable from within App-V bubble that we cannot have shortcut of.

Example –

We want to run some executable from within App-V virtual bubble with some external random input files. We may have batch file with logic to call executable with n number of input files.

Implementation –

How to go inside the virtual bubble –

For implementing above scenario, we have to go inside virtual bubble through command prompt. You can go inside virtual bubble using the command – 

cmd.exe /appvve:<PACKAGEGUID_VERSIONGUID>

You can get PackageGUID and VersionGUID using the PS command Get-AppvClientPackage –All

The above command will take you to the command prompt inside the virtual bubble. Now you can navigate to different folders with bubble. Please note that “dir” on the command prompt might not show the name of actual application folder. You may have to do “cd <name/location of application>”.

Now in XenApp, we will need to publish above command for the users. When they will launch the published icon, they will get the command prompt. User will have full access on the bubble and they can execute any executable from the command prompt.

Important point here is that though user can add any file/folder in virtual location (bubble) , actual App-V package in the XenApp Cache is pristine and will not have any changes done by any user. This means App-V package is read-only and whatever is getting written by users, is written only in their virtual bubble and when they logs it off, bubble gets destroyed.

I tested it by exiting the command prompt and re-launching it again from web interface and I have not found those files again that were added in the bubble before. With it said, users is writing to their own private virtual bubble only and it will not impact other user’s bubble. Every user will have their private virtual bubble and they will not see other user’s bubble.

Advertisements

PowerShell–Find and replace files

Scenario – A file is present at many locations in folder and its subfolders. We need to find the file in all the locations of given path and replace it with the new updated file. The new updated file name may be same as old one or may be different too…

Above scenario is implemented using PowerShell script –

——————————————————————————

<#


.Synopsis
     Search and Replace File


.Discription
     It searches and then replaces file.


#>


param ([parameter(Mandatory=$True,Position=0)]
         [string][ValidateNotNullOrEmpty()]$FileLocationToSearch,


        [Parameter(Mandatory=$true, Position=1)]
         [string][ValidateNotNullOrEmpty()]$FileName,
        
         [Parameter(Mandatory=$true, Position=1)]
         [string][ValidateNotNullOrEmpty()]$FilelocationForReplace)       
      



$FilePaths = Get-ChildItem -Path $FileLocationToSearch -Recurse -File | Where-Object {$_.Name -eq $FileName} | Select -ExpandProperty FullName


foreach ($File in $FilePaths)
{
     $DestFilePath = Split-Path -Path $File
     Write-Host “—————————————————–”
     Write-Host $File  
     Remove-Item $File  
     Write-Host $File “DELETED!!!”
     Copy-Item -Path $FilelocationForReplace -Destination $DestFilePath -Force
     Write-Host $FilelocationForReplace ” — Copied Successfully to $DestFilePath”
     Write-Host “—————————————————–“
}

————————————————————————————————————–

Flow of program –

1) It is finding file from all folders and subfolders from a given location as input

2) In foreach loop, for every location found, it is deleting the found file and then copying the updated file back on that location

             —–End of Article—–

TFS Release Definition – Custom variables and values

Scenario – Sometimes we need to use some logic based data in a variable in Release definition task like datetime value. Example, You want to create backup folder with datetime folder to preserve the backups.

There is no direct way in TFS for achieving it. TFS does have some user defined variables that can be used for defined values but for such requirements in release, it does not have any.

To implement it, I did below steps –

  1. I defined variable in release definition and set the value to “none”. Example here is – backupfoldername and value is none.
  2. I added task for PowerShell script and added below Inline script to set the above defined variable with date time value –

$date= (Get-Date).ToString(‘MM.dd.yyyy-hhmmsstt’)

Write-Host “##vso[task.setvariable variable=backupfoldername]$date”

  1. Finally I added the release task where I wanted to use it and used it as $(variablename) like $(backupfoldername). It worked!

TFS–MAC build–Git error

I was trying to build one of my iOS based application in MAC from TFS. While trying to do so, I was getting error –

“error setting certificate verify locations:

  CAfile:/etc/ssl/certs/ca-xxxxx.crt

  CApath:/etc/ssl/certs/..”

Error screenshot is given below as well…

image

I was struggling to resolve it and I have not found much information on internet.

Finally, I am able to resolve it and wanted to share it here so that it can help all…

I looked into “system” and “global” git files and they were setup properly with all the required values of the certificates.

You can view these files using below commands –

System file – “git config –system –list

Global file – “git config –global –list

I have to give full access on the certs folder (/etc/ssl/certs) using the command –

sudo chmod –R 777 .

With it, it worked!

Important note – Many have given solution to turn off the SSLVerify which is absolutely not recommended way from security perspective.

How to publish build artifacts from iOS builds to Windows based drop location

The requirement is to publish the TFS build artifacts (output) of Xamarin.iOS or any iOS based application to the file share (drop location) based on windows environment.

As per the MS documentation, Publishing artifacts from a Linux or macOS agent to a file share (drop location) is not supported, we have to use some other way to achieve the same behavior.

Here is the option we have implemented and can be used –

1) In the build definition, add the task to publish the artifacts.  Select the Artifact Type as “Server” as shown below –

image

Note – This will save all the artifacts on the TFS database (SQL Server) and so it is recommended to have the retention policy in place to delete the unwanted artifacts from the TFS database.

2) Now, when you build the application using above publish option, once the application is build successfully, you can download all the Artifacts from the TFS web portal as shown below –

image

3) Now, if you want to have the build Artifact on some file share, you can not use the above task in iOS as said before that it is not supported for MAC agent. The workaround would be to have a release definition just to copy the build artifacts to the drop location with “Continuous Deployment” as a trigger so that as soon as build is done successfully in MAC, its build artifacts will be copied to the file share. This way you will have your build output in the file share just like the way you do for windows based agents.

image

a) Release definition creation screenshot

image

b) Release Definition with Task screenshot

TFS – Release automation – IIS based Websites

Here is the best practice for the release automation of IIS based applications –

Scenario 1 –

New Web applications –

Add below tasks in the given order –

  1. Copy task – Copy the website published code from build drop location to web server.
  2. Tokenization task – task for replacing required values in different environments.
  3. Any other requirement on the web folder like subfolder creation or folder permissions
  4. IIS Website creation task – Task to create website and its application pool. It also configures various required settings in IIS like authentication etc.
  5. Application pool start/stop task – Select the “Restart” option to restart the application pool.

Scenario 2 –

Upgrade Web applications –

Add below tasks in the given order –

  1. Application pool start/stop task – Select the “STOP” option to stop the application pool.
  2. Backup utility task – Take the backup of the existing web folder.
  3. Copy task – Copy the website updated published code from build drop location to web server.
  4. Tokenization task (If there are changes in config files)– task for replacing required values in different environments.
  5. Any other requirement on the web folder like subfolder creation or folder permissions
  6. Application pool start/stop task – Select the “START” option to start the application pool.

Please use below tasks for –

  1. IIS Website Application pool start/stop/restart (https://marketplace.visualstudio.com/items?itemName=mohdaslamansari.build-task)
  2. Folder permissions (https://marketplace.visualstudio.com/items?itemName=mohdaslamansari.FolderPermissions)
  3. Backup utility (https://marketplace.visualstudio.com/items?itemName=mohdaslamansari.backuputility)

clip_image001

 

            —–End of Article—–

Microsoft Marketplace Extension – Backup Utility

******Making Automation easy – Plug & Play Plugins********

In many releases, we get requirement to take the backup of all the files and folders of website before performing any updates on them. I have implemented this requirement using PowerShell in TFS. It needs source location from where to take the backup and the destination location where the backup will be placed.

To make it simple and easy to use, I created MS marketplace extension and published the same in the Microsoft marketplace.

It is now available publically to everyone to download and use.

Direct link – https://marketplace.visualstudio.com/items?itemName=mohdaslamansari.backuputility

Marketplace link – https://marketplace.visualstudio.com/

I have copied the sourcecode to GitHub for getting code contribution from public.

GitHub link – https://github.com/mdaslamansari/backuputility

clip_image001

clip_image001[4]

Task (UI) in release definition –

clip_image001[6]

Here is the PowerShell script at its core –

image

 

    —End of Article—-