Copying a NuGet repository, all packages and all versions, using PowerShell

Today I needed to copy a full repo to my machine, and then I found some good ready-to-use commands in PowerShell. I created this based on the solution in this post, but it didn’t suffice for me as I would like to have all versions downloaded and not only the lastest.

It is simple, just we have to do it:

# Set the nuget source as trusted first, then it won't show any pop-ups
Set-PackageSource -Name NuGet-Source -Trusted

# Downloading...
Find-Package -AllVersions -Source NuGet-Source| ForEach-Object {
        Install-Package -Name $_.Name -MaximumVersion $_.Version -Destination 'C:\Temp\Nuget\' -Source NuGet-Source -SkipDependencies
}

 

Sometimes for some reason, the code above doesn’t return all packages from the remote repository. Then I found a way to do it from Package Manager Console within Visual Studio.
First I create a list of all packages this way (this code must be executed from Visual Studio, in Package Manager Console):

Get-Package -ListAvailable -AllVersions -IncludePrerelease -PageSize 122831 | ForEach-Object { $id = $_.Id; $_.Versions | ForEach-Object { ($id + ',' + $_.Version) } } > C:\Temp\Nuget\AllPackages.txt

Then I use PowerShell (out of Visual Studio):

Get-Content C:\Temp\Nuget\AllPackages.txt | ForEach-Object {
$package = $_.Split(',')
$id = $package[0]
$version = $package[1]

$path = ('C:\Temp\Nuget\' + $id + '.' + $version)

Write-Host $path
if(! (Test-Path -Path $path)) {
Install-Package -Name $id -MaximumVersion $version -Destination 'C:\Temp\Nuget\' -Source NuGetSource -SkipDependencies -AllowPrereleaseVersions
}
}

DevOps – High-level overview

DevOps is a cultural change, is about reducing costs and solve complex deliveries in a shorter time.
It is about having a better process to solve issues, instead of keeping the responsibility on some specific people that were responsible for the implementation. Usually, the companies do not have some quick way to solve issues, or to deploy the solution quickly to the production. Sometimes the solution is quickly done in the code bug take ages to reach the production.

DevOps also will help to keep the process lean, removing waste, sometimes the projects are overloaded with extra stuff that simply will slow down the progress. It is not easy to filter out the waste, but it is crucial and the goal for DevOps.

It is all about adding more value to the customer. That’s the focus, the other side effects are related to it, so it will push your project to eliminate waste and reduce the cycle time.

References:
https://en.wikipedia.org/wiki/DevOps
https://app.pluralsight.com/library/courses/devops-big-picture/table-of-contents

Easy way to upload TFS 2015 build tasks (using TFX)

First of all, we are talking about TFS 2015 build tasks, TFX tool and powershell tasks.

What do you need?

  • TFX installed
  • json file
  • ps1 file
  • full TFS access

 

How to authenticate with TFX:

I’m using basic authentication,

tfx login –auth-type basic

It will ask for:

Service-URL: http://tfs.yourdomain.com:8080/tfs

Username: domain\ID

Password: password

 

Once authenticated, go to the folder where your files are and execute this command to push all to the server:
tfx build tasks upload –task-path .\

 

The json file

Use another task as base for your new task, you must set a new GUID for your new task, it will identify your task. You must increase the version before each upload. And you can define the GUI in this file.

TFS API to manipulate your server Workspaces

Hi all, one in a while we need to do some changes within our TFS Build process template, and a easy way to do it is using powershell in pre or post build command.

I will add a sample code to find the current workspace and then you can program what you need from this point on.

Code:

# load the needed client dll’s
[void][System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.TeamFoundation.VersionControl.Client”)

#here I’m considering that your workspace is one folder up

$rootBuildPath = (get-item $PSScriptRoot ).parent.FullName

#here I get the workspaces set for that local folder

$workspaceInfos = [Microsoft.TeamFoundation.VersionControl.Client.Workstation]::Current.GetLocalWorkspaceInfoRecursively($rootBuildPath)

#here I can get the tfs collection

$tfsCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($workspaceInfos[0].ServerUri);

#then I can get the version control service

$vc = $tfsCollection.GetService([type] “Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer”);

#and for example, download something

$fileXml = Join-Path -Path $rootBuildPath -ChildPath “file.xml”
$itemToDownload = $vc.GetItem(“$/teamProjectName/file.xml”, [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest);
$itemToDownload.DownloadFile($fileXml)

 

It works for all xaml builds and also for the new build system.

OpenWrt – OS for embedded devices

Hi there,

If you are looking for some powerful SO for your routers, modems, repeaters I can say that you should give a try to OpenWrt. I tried it and I install in my two devices here:

TL-WA850RE-01[1]
TL-WA850RE
First I installed in my TL-WA850RE, using the default firmware and I had no issues. Set it up using the GUI Luci, and it worked well as expected. Seems that it works better than the original firmware, and I have way more options to set up this little repeater. Actually now it works like a regular router as well as a repeater. OpenWrt makes any device a repeater easily, I tested it with my second device.

 

 

TL-WR841N-01[1]
TL-WA850RE
My second device TL-WR841N, it’s a bit more powerful, but it has only 4MB of storage, and it is a problem sometimes when you want to install a custom software. I had installed the main latest trunk, it worked but I had no GUI. Then when I tried to install the GUI got issues with my storage. Using the forum I was able to find another way, and all is described in the forum, click here to check.

After installed the GUI I was able to set up my network quickly. Also it’s possible to make any regular router a repeater, I tried here and it works pretty well (look on YouTube how to set it up). Also I was able to define some host names, and point then to some specific IP address, make my local network more accessible.

OpenWrt also has a full dashboard to control what is going on in your network. If you like to change things and play with your devices I recommend that. Just be careful to not brick your devices, read the forum and act knowing that you may break something. Try to understand things before doing them, just it is enough. Good luck!

VSCode + Git – Step-by-Step

Hey guys, I’m amazed with VSCode, it’s simple and powerful!

My idea with this post is to make it more simplified, and clear for the ones that are just starting with code.

You must have in your machine VSCode and Git installed!

Also you must have a repository ready to be used, in my case I’m using VSTS:
Git

Now to setup your environment:

  1. Open the command prompt in the folder you want to add your project files
    GitClone
  2. Press enter and then your code will be cloned locally
    GitCloning
  3. Now to open in your VSCode just typing “code .” in the project’s folder
    (This is the folder where are your project files)
    Then you will be able to see the project:
    CodeProject
  4. Now go to Git tab
    GitTab
    Now change some file and save, and then it will appear in the Git tab as a change
    GitChange.png
  5. Now you can add a message and Commit All
    GitCommitAll
    At this point you committed your code to your local repository, then if you and to send it to the remote Git, you must sync your code.
  6. Sync to the origin
    GitSync
    Once you press sync, it will execute a git pull and then a git push, that way it can ensure that you are integrating all changes locally and then sending all integrated code back to the server. Conflicts may appear, depending on the changes done pushed to the server previously, in that case VSCode will show for you the conflict and you may use its tool to fix the conflict.

 

 

[RM-Tools] xCopy Deployer x Custom xCopy Deployer?

Today I was using the built-in xCopy Deployer from Release Management, then I notice that everytime I was copying files, it was copying the whole folder structure.

It happens because the RM tool xCopy Deployer add by default the parameter /e, which creates the folder structure for you, even if you don’t need it.
To make it more flexible, I created a new xCopy tool, called xCopyPS, because it’s in Powershell Alegre

image

For me it’s better to define what are the custom parameters for it, instead of having a common behavior and some extra folder left in my destination folder.

Also you may create it not using powershell, in that case the log file won’t be so nice Smiley piscando

Source code in ps1:

################################################################################## # Define input parameters. param ( [string]$SourceFileFolder = $(throw File or folder name must be provided.), [string]$DestinationFileFolder = $(throw File or folder name must be provided.), [string]$CustomParams = “” #“for example: /y/i/e/f” ) cls ################################################################################## # Output the logo. xCopy PowerShell RM tool xCopy using PowerShell and with possibility to use System Variables It may run all params accepted by the xCopy using the CustomParams Created by Fabio Stawinski.`n ################################################################################## # Output execution parameters. Executing with the following parameters: SourceFileFolder: $SourceFileFolder DestinationFileFolder: $DestinationFileFolder CustomParams: $CustomParams`n Command: xcopy $SourceFileFolder $DestinationFileFolder $CustomParams &xcopy $SourceFileFolder $DestinationFileFolder $CustomParams