Requirements:
You must already have an empty repo created on either SVN/GIT/TFS
This means there must be no build files related to our build process in your repoYou must checkout/clone the repo onto your machine so it is ready to work with
Time Management:
It should take around 20-30 minutes to do the whole setup if you have never done it before
Once you have done it a few times, it should take around 10-20 minutes
Notes:
- If you already have committed code, you will need to refactor your structure to match the following:
- Filenames used here are examples
- The lib directory must only contain libraries that cannot be installed via nuget packages or some form of package manager within your IDE
├ src/ │ ├ *.sln │ ├ ProjectName/ │ > ├ *.*proj │ ├ GulpProjectName/ │ > ├ gulp.js │ ├ NPMProjectName/ │ > ├ app.js ├ lib/ │ ├ LibName/ │ > ├ *.dll
- Create the following directories in your repo:
- src (in the root of your repo)
- lib (in the root of your repo)
- Create as many directories in the src/ dir according to the projects you are going to add to this repo
2. Add your project source code into the relevant project directories (within the project dir, within the src dir)
Notes:
- You can skip this step if you already have a repo setup with the above directory structure
- The .sln (Visual Studio Solution File) must be added directly into the src/ dir
Notes:
- Open your project in your IDE of choice (If you build using an IDE)
- Run your build and make sure it succeeds
- Do not continue until you have a successful build
Notes:
Add relevant binary/generated files to your ignore list
Add the following as well:
- /[Bb]uild
- /[Cc]onfig
- /[Dd]ist
- /[Ll]ogs
- /[Tt]ools
- /[Bb]uild[Ll]ogs
- [Pp]ackages/
- /*.log
Notes:
- Close your IDE before deleting any files
What to delete?
- bin, obj directories
- *.user, *.suo files
Notes:
- git commit -m "I love GIT and my code works!"
- svn commit -m "I want to move to GIT but my code works!"
7.1. Go to System.Utility.DERBS.Bootstrap and download the latest nuget package.
7.2. Once downloaded, open the package using 7-Zip (Or any compatible zip archive software)
Notes:
Quick file explanations:
bootstrap.ps1
Handles automatic updating of the build system within your project so that we can make bugfixes that propogate automatically
Pulls down our config directory which holds all of our build targets to defined how to actually build your project(s)
Pulls down tools required to build your project(s) or for tests and reporting
Pulls down any additional tools defined in the NugetTools.Includebuild.proj
Stores your build definitions
This file defines what and how your projects must be built, versioned or testedBuild.Targets
Defines all referenced .targets that the build must load to for your buildSetupBuid.bat
Sets your build up by adding references in the *.proj files
References theCommonAssemblyInfo.cs
Adds anAfterBuildstep to copy the built artifacts to the/Builddirectory
├ _src/ -> ├ src/ │ ├ CommonAssemblyInfo.g.cs -> │ ├ CommonAssemblyInfo.g.cs ├ Bootstrap.ps1 -> ├ bootstrap.ps1 ├ Build.bat -> ├ Build.bat ├ Build.proj -> ├ Build.proj ├ Build.targets -> ├ Build.targets ├ NugetTools.include -> ├ NugetTools.include ├ SetupBuild.bat -> ├ SetupBuild.bat ├ SetupBuild.ps1 -> ├ SetupBuild.ps1 ├ Version.include -> ├ Version.include ├ deploy/ -> ├ deploy/ │ ├ DeployableNugetPackageTemplate/ -> │ ├ DeployableNugetPackageTemplate/ │ > ├ Template.nuspec.dist -> │ > ├ Template.nuspec.dist │ > ├ PostDeploy.ps1 -> │ > ├ PostDeploy.ps1 │ > ├ PreDeploy.ps1 -> │ > ├ PreDeploy.ps1 │ > ├ DeployFailed.ps1 -> │ > ├ DeployFailed.ps1 │ > ├ Deploy.ps1 -> │ > ├ Deploy.ps1 │ ├ DeployableNugetPackageTemplate.Config/ -> │ ├ DeployableNugetPackageTemplate.Config/ │ > ├ Template.Config.nuspec.dist -> │ > ├ Template.Config.nuspec.dist │ > ├ PostDeploy.ps1 -> │ > ├ PostDeploy.ps1 │ > ├ PreDeploy.ps1 -> │ > ├ PreDeploy.ps1 │ > ├ DeployFailed.ps1 -> │ > ├ DeployFailed.ps1 │ > ├ Deploy.ps1 -> │ > ├ Deploy.ps1 │ ├ LibraryNugetPackageTemplate/ -> │ ├ LibraryNugetPackageTemplate/ │ > ├ Library.Template.nuspec.dist -> │ > ├ Library.Template.nuspec.dist
Update
<ProductName>Template</ProductName>with your products name (No spaces)
Update<ProductFullName>Template</ProductFullName>with your products full name (Can contain spaces)
Update the default project reference
<Project Include="src\Template.sln"/>to point to your .sln file (duplicate this line to add multiple files)
If you have other types of projects, there are examples included in the build.proj
If you do not have a*.slnfile, you will need to comment out the above referenced line and then go onto step #8.3
Uncomment the reference to the
*.targetsfor the required feature (Using a proper dev's text editor... like notepad... ++)
If you are not building any C# projects, you must comment out<Import Project="config\Standard.Build.targets"/>
Notes:
- If you are asked to commit, say
No- If it does not open CMD, then open CMD in the current directory and call it manually
SetupBuild.batErrors:
SetupBuild.ps1 cannot be loaded because the execution of scripts is disabled on this system
- You will need to open powershell as administrator and run
Set-ExecutionPolicy Unrestricted
Commands:
.\will setup all projects within your repo- Absolute path of your projects
Notes:
- Pressing enter will start the setup
- Let it run a build but DON'T COMMIT. (If the build fails, there could be a config error in your setup)
Notes:
- Our build process will build and copy the built dlls/exes into the /Build/{ProjectAssemblyName}/ directory
- NPM/Gulp/Grunt projects will not be copied to the /Build directory but more than likely a /dist directory within the project dir
- Go into the /Build/{ProjectAssemblyName}/ directory and check your dlls/exes were outputted
- Or check in the dist directory within the project directory if is a NPM project
Notes:
- .nuspec vs .nupkg
.nuspec- NuGet specification file (used to define what a NuGet package will look like).nupkg- NuGet package (A fancy ZIP file with extra information)
Notes:
In order to publish to our NuGet feeds, you will need to have the correct NuGet package Ids
Go to Automated Deployments Naming Standards and work out what your nuget package id(s) will need to be.
10.2. List (On notepad, paper or simply remember - just for reference to make the following easier) the NuGet package Ids and their package type.
Package Types:
- Library packages (
LibraryNugetPackageTemplate) (packages installed using Nuget Package Manager in VS) go tohttp://nugetlib/- Deployable packages (
DeployableNugetPackageTemplate) (packages deployed using Octopus) go tohttp://devget/- Config packages (
DeployableNugetPackageTemplate.Config) (packages containing web.config or other purely configuration related files) go tohttp://devget/&http://testget/&http://liveget/
What files to delete per package type not required:
Library
├ deploy/ │ ├ LibraryNugetPackageTemplate/ │ > ├ Library.Template.nuspec.distDeployable
├ deploy/ │ ├ DeployableNugetPackageTemplate/ │ > ├ Template.nuspec.dist │ > ├ PostDeploy.ps1 │ > ├ PreDeploy.ps1 │ > ├ DeployFailed.ps1 │ > ├ Deploy.ps1Config
├ deploy/ │ ├ DeployableNugetPackageTemplate.Config/ │ > ├ Template.Config.nuspec.dist │ > ├ PostDeploy.ps1 │ > ├ PreDeploy.ps1 │ > ├ DeployFailed.ps1 │ > ├ Deploy.ps1
Notes:
You only delete the .nuspec, .ps1 files and directory that you don't want to keep or that is unrelated to your build.
Eg: Delete
deploy/LibraryNugetPackageTemplatedirectory (which deletes all files within) as we are deploying our project using Octopus and not pushing a library to be used in other projects
Duplicate the relevant nuget package type directory
- EG: If you have 2 Library packages, make a copy of the
LibraryNugetPackageTemplatedirectory so now you would have something like this:
├ deploy/ │ ├ LibraryNugetPackageTemplate/ │ > ├ Library.Template.nuspec.dist │ ├ LibraryNugetPackageTemplate - Copy/ │ > ├ Library.Template.nuspec.dist
Notes:
If your NuGet package id is: (EG) Internal.Web.Canvas
Then you would rename one of the directories fromDeployableNugetPackageTemplatetoInternal.Web.Canvas(According to the package type) Examples:
LibraryNugetPackageTemplate->Internal.Library.Canvas.SDKDeployableNugetPackageTemplate.Config->Internal.Web.Canvas.ConfigDeployableNugetPackageTemplate.Config->Banking.Service.PAPI.ConfigLibraryNugetPackageTemplate->Banking.Library.PAPI
Notes:
If your NuGet package id is: (EG) Internal.Web.Canvas
Then you would go into the relevant directory, eg:Internal.Web.Canvas(which wasDeployableNugetPackageTemplate) and rename theDeployableNugetPackageTemplate.nuspec.disttoInternal.Web.Canvas.nuspecBy dropping the .dist you now make it a valid nuspec file Examples:
Internal.Library.Canvas.SDK/LibraryNugetPackageTemplate.nuspec.dist->Internal.Library.Canvas.SDK/Internal.Library.Canvas.SDK.nuspecInternal.Web.Canvas.Config/DeployableNugetPackageTemplate.Config.nuspec.dist->Internal.Web.Canvas.Config/Internal.Web.Canvas.Config.nuspecBanking.Service.PAPI.Config/DeployableNugetPackageTemplate.Config.nuspec.dist->Banking.Service.PAPI.Config/Banking.Service.PAPI.Config.nuspecBanking.Library.PAPI/LibraryNugetPackageTemplate.nuspec.dist->Banking.Library.PAPI/Banking.Library.PAPI.nuspec
Notes:
You can open the .nuspec files using a text editor (like notepad... ++)
.nuspec files are XML files
Examples:
Internal.Library.Canvas.SDK-><id>Template</id>-><id>Internal.Library.Canvas.SDK</id>
Internal.Web.Canvas.Config-><id>Template</id>-><id>Internal.Web.Canvas.Config</id>
Banking.Service.PAPI.Config-><id>Template</id>-><id>Banking.Service.PAPI.Config</id>
Banking.Library.PAPI-><id>Template</id>-><id>Banking.Library.PAPI</id>
10.7.2 Update the <file src="..\deploy\Template\*.ps1" /> (*.ps1 reference only) file reference element with the relevant nuget package id.
Examples:
Internal.Library.Canvas.SDK-><file src="..\deploy\Template\*.ps1" />-><file src="..\deploy\Internal.Library.Canvas.SDK\*.ps1" />
Internal.Web.Canvas.Config-><file src="..\deploy\Template\*.ps1" />-><file src="..\deploy\Internal.Web.Canvas.Config\*.ps1" />
Banking.Service.PAPI.Config-><file src="..\deploy\Template\*.ps1" />-><file src="..\deploy\Banking.Service.PAPI.Config\*.ps1" />
Banking.Library.PAPI-><file src="..\deploy\Template\*.ps1" />-><file src="..\deploy\Banking.Library.PAPI\*.ps1" />
-
Library package type
Notes:
Library packages should only contain the single DLL and/or pdb of your project and can contain other config/content related files that are required by your project
All other dlls/pdbs should NOT be referenced as they should be dependencies of this nuget package-
Update the
<file src="Template\MyLibrary.dll" target="lib\net4" />reference to point to the dll from your projectNotes:
The file references are all relative to /Build directory
You can use wild card referencesExamples:
-
Single DLL:
Internal.Library.Canvas.SDK-><file src="Template\MyLibrary.dll" target="lib\net4" />-><file src="CanvasSDK\CanvasSDK.dll" target="lib\net452" />
Banking.Library.PAPI-><file src="Template\MyLibrary.dll" target="lib\net4" />-><file src="PAPI\PAPI.dll" target="lib\net2" /> -
DLL with PDB:
Internal.Library.Canvas.SDK-><file src="Template\MyLibrary.dll" target="lib\net4" />-><file src="CanvasSDK\CanvasSDK.*" target="lib\net452" />
Banking.Library.PAPI-><file src="Template\MyLibrary.dll" target="lib\net4" />-><file src="PAPI\PAPI.*" target="lib\net2" />By using a wildcard for the file extension we include both the .dll and .pdb files
The assembly info does not need to match the nuget package id as the nuget package id is only used during the CI/Deployment pipeline
Q: Why is the example referencing PAPI.dll rather than Banking.Library.PAPI.dll
A: The PAPI.dll file is outputted by the build which has it's assembly info defined as PAPI
-
-
- Update the
<authors>element with your teams email address.
For deployment packages, you will get an email at that address when your package is promoted.
- Update
<description>with your app/library description. - Update
<releaseNotes>accordingly - Update
<tags>with your NuGet package id with spaces instead of full stops
Eg:
Internal.Web.Minion.CoretoInternal Web Minion Core
- Go to the project where you want to add your new build
Eg:
https://teamcity/project.html?projectId=ConfigurationUtilities_BuildConfig&tab=projectOverview
- Click
Edit Project Settingson the top right of the page.
if you do not see this, you do not have permissions, please log a call to give you project admin permissions https://fw.minion/cfggenr
- Click
Create Build Configuration - Select
Manualon the drop down - Enter the
NuGet package idas theNameof the new build configuration. - Select the
based on templatedepending on the following:
GIT version control:
Normal build: Build Template (Git)
Config build: Config Build Template (Git)SVN version control:
Normal build: Build Template (Svn)
Config build: Config Build Template (Svn)
- For SVN (normal and config based builds):
Fill in the
Repo-Pathparameter with yourbranch/trunk referenceEg:
trunkorbranches/{MyBranchname}
- For Config builds:
Fill in the
OctopusProjectNameparameter with your Octopus project name
This will most likely be your config NuGet package idEg:
Internal.Web.Minion.Api.Config
Fill this in even if you aren't going to use it yet
- Click the
Createbutton.
Notes:
Don't worry about filling the other parameters if you don't need to, the defaults are fine
-
Click
Version Control Settingson the left of the page -
Click
Attach VCS root -
If you already created a VCS root for this project:
- Select the existing VCS url from the
Attach existing VCS rootdrop down.- Click
Attach
- If you have a new build and you haven't created one:
- Select GIT/SVN under the
Create new VCS rootdrop down.- Click
Create
- Paste the repo url into the
Fetch URLtext box.Leave
Push URLblank
- Add the following to the
Branch specificationtext box:+:refs/heads/*- Change
Username styletoAuthor Name and Email- Change
Authentication methodtoUploaded Keyand selectbuild@mgsops.net.- Check the
Convert line-endings to CRLFcheck box
- Paste the repo url into the
URLtext box folled by%Repo-Path%.
Eg:
https://dersvn02/repos/CasperRepo/Caiman/Applications/%Repo-Path%
- Enter
MGSOPS\Buildin theUsernamefield - Leave
Passwordblank - Change
Externals supporttoCheckout, but ignore changes
Now
log a callfor someone in the DevOps team to enter the password - https://fw.minion/cfgbuildp
- Click
Create
Notes:
You do not have to wait for the password to be filled to continue with this process
Notes:
If you setup a Config build template but your Octopus project doesn't exist yet, your build will fail but that is okay, it will succeed as soon as the project is promoted to LIVE
- Click
Runon the top right to run your build.