lennybacon.com
BUILD BUILD BUILD
Daniel Fisher
lennybacon.com
Daniel Fisher
• Freelancer
– Developer, Architect, Coach, Trainer
• Justcommunity.de
– Mit-Gründer und Vors...
lennybacon.com
EFFICIENT COMMUNICATION…
lennybacon.com
© Daniel Fisher
Build, Build, Build
Daniel Fisher | info@lennybacon.com
lennybacon.com
Objectives
Serious Software Development
Product Delivery
C#/.NET
AppDomains
MsBuild
REST APIs
AngularJS
Cod...
lennybacon.com
Agenda
• What is a Build?
• MsBuild
• Hosting MsBuild in ASP.NET (YABS?)
• MsMetrics, FxCop & Co.
• Nunit
•...
lennybacon.com
WHAT IS A BUILD?
lennybacon.com
https://www.flickr.com/photos/86931652@N00/392470198
lennybacon.com
lennybacon.com
MSBUILD
lennybacon.com
News?
• MSBuild is now installed as part of Visual
Studio rather than as part of the .NET
Framework.
– The ...
lennybacon.com
Properties
• Named Value Pairs
– Variables of the Build script
• Part of a PropertyGroup
• Referenced as sc...
lennybacon.com
Items
• Items are Inputs
– Source files, references…
• Part of a ItemGroup
• Items are referenced as groups...
lennybacon.com
Targets and Tasks
• Tasks are Steps that are performed in a build
process as Part of a Target
• A build can...
lennybacon.com
Clone-Repository
Update-Version
Update-Dependencies
Generate-Code
Compile-Code
Test-Code
Analyze-Code
Docum...
lennybacon.com
Custom Tasks
public class MyTask : Task
{
override void Execute()
{
//TODO: Write your stuff here ...
}
}
lennybacon.com
http://www.flickr.com/photos/64550677@N06/12829392063/
lennybacon.com
http://www.flickr.com/photos/toaireisdivine/7245696024/
lennybacon.com
https://www.flickr.com/photos/seelensturm/4046487038
lennybacon.com
YET ANOTHER BUILD SERVER?
lennybacon.com
© Daniel Fisher
lennybacon.com
Clone-Repository
Update-Version
Update-Dependencies
Generate-Code
Compile-Code
Test-Code
Analyze-Code
Packa...
lennybacon.com
lennybacon.com
© Daniel Fisher
lennybacon.com
© Daniel Fisher
lennybacon.com
© Daniel Fisher
lennybacon.com
lennybacon.com
https://www.flickr.com/photos/hectoralejandro/3967217852
lennybacon.com
lennybacon.com
API
GET /api/builds
POST /api/builds
GET /api/builds/{slug}
PUT /api/builds/{slug}
PATCH /api/builds/{slug}...
lennybacon.com
lennybacon.com
Custom Verbs with Web API
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace WebAppl...
lennybacon.com
https://www.flickr.com/photos/25726169@N03/8600834488
lennybacon.com
HOSTING MSBUILD
lennybacon.com
References
• Microsoft.Build.dll
• Microsoft.Build.Engine.dll
• Microsoft.Build.Framework.dll
lennybacon.com
Programmatically run a build
public bool Run(string msBuildFile, Dictionary<string, string> properties)
{
v...
lennybacon.com
https://www.flickr.com/photos/jlauletta/14058076975
lennybacon.com
APPDOMAIN ISOLATION
lennybacon.com
Run in another AppDomain
var appDomainSetup = new AppDomainSetup {
PrivateBinPath = appPath,
ApplicationBas...
lennybacon.com
https://www.flickr.com/photos/ryan2point0/4986543660
lennybacon.com
READ LENNYBACON.COM
FOLLOW @LENNYBACON
LINK LINKEDIN.COM/IN/LENNYBACON
XING XING.COM/PROFILE/DANIEL_FISHER
...
Upcoming SlideShare
Loading in...5
×

2014 - DotNetCologne: Build, Builder, Am Buildesten

370

Published on

Ohne den Build ist Code nichts. Mit Continous Integration und Delivery wird er auch für nicht-Programmierer wichtig. Der Build-Server ist der Herzschlag eines Software-produzierenden Teams.
Aber würdigen wir das auch so? Wer liest den schon Mails von Jenkins? Weg guckt auf das Dashboard von TeamCity? Aus einer Anforderung in einem Projekt hat sich Daniel gefragt, was man anders machen kann und das eine oder andere selbst implementiert. In dieser Session gibt es Ideen, Konzepte, Lösungen und Umsetzung in C# Code und JavaScript mit AngularJS.

Published in: Software
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
370
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

2014 - DotNetCologne: Build, Builder, Am Buildesten

  1. 1. lennybacon.com BUILD BUILD BUILD Daniel Fisher
  2. 2. lennybacon.com Daniel Fisher • Freelancer – Developer, Architect, Coach, Trainer • Justcommunity.de – Mit-Gründer und Vorstand • nrwconf.de – Mit-Gründer und Organisator • netug-niederrhein.de – Mit-Gründer und Ex-Leiter • microsoft.com – Certified Professional Developer – Business Platform Technology Advisor • lennybacon.com – Blog • twitter.com – @lennybacon
  3. 3. lennybacon.com EFFICIENT COMMUNICATION…
  4. 4. lennybacon.com © Daniel Fisher Build, Build, Build Daniel Fisher | info@lennybacon.com
  5. 5. lennybacon.com Objectives Serious Software Development Product Delivery C#/.NET AppDomains MsBuild REST APIs AngularJS Code Quality NuGet
  6. 6. lennybacon.com Agenda • What is a Build? • MsBuild • Hosting MsBuild in ASP.NET (YABS?) • MsMetrics, FxCop & Co. • Nunit • …
  7. 7. lennybacon.com WHAT IS A BUILD?
  8. 8. lennybacon.com https://www.flickr.com/photos/86931652@N00/392470198
  9. 9. lennybacon.com
  10. 10. lennybacon.com MSBUILD
  11. 11. lennybacon.com News? • MSBuild is now installed as part of Visual Studio rather than as part of the .NET Framework. – The current MSBuild version number is 12.0. If you want to install MSBuild separately, download the installation package from MSBuild Download (http://go.microsoft.com/fwlink/?LinkId=309745).
  12. 12. lennybacon.com Properties • Named Value Pairs – Variables of the Build script • Part of a PropertyGroup • Referenced as scalar values – Using the $() syntax <PropertyGroup> <AssemblyName>MyAssemblyName</AssemblyName> </PropertyGroup>
  13. 13. lennybacon.com Items • Items are Inputs – Source files, references… • Part of a ItemGroup • Items are referenced as groups – Using the @() syntax <ItemGroup> <CSFile Include="MyLibClass1.cs" /> <CSFile Include="MyLibPropertiesAssemblyInfo.cs" /> <Reference Include="System.dll" /> </ItemGroup>
  14. 14. lennybacon.com Targets and Tasks • Tasks are Steps that are performed in a build process as Part of a Target • A build can be told which target(s) to execute <Target Name="Compile"> <MSBuild Projects="MyLibraryMyLibrary.sln" Properties="Configuration=Release" /> </Target>
  15. 15. lennybacon.com Clone-Repository Update-Version Update-Dependencies Generate-Code Compile-Code Test-Code Analyze-Code Document-Code …
  16. 16. lennybacon.com Custom Tasks public class MyTask : Task { override void Execute() { //TODO: Write your stuff here ... } }
  17. 17. lennybacon.com http://www.flickr.com/photos/64550677@N06/12829392063/
  18. 18. lennybacon.com http://www.flickr.com/photos/toaireisdivine/7245696024/
  19. 19. lennybacon.com https://www.flickr.com/photos/seelensturm/4046487038
  20. 20. lennybacon.com YET ANOTHER BUILD SERVER?
  21. 21. lennybacon.com © Daniel Fisher
  22. 22. lennybacon.com Clone-Repository Update-Version Update-Dependencies Generate-Code Compile-Code Test-Code Analyze-Code Package-Output Sign-Package Deploy-Package Test-DeploymentSign-Output Publish-Package Notify-Stakeholders Document-Code Generate-Manual Report-Results
  23. 23. lennybacon.com
  24. 24. lennybacon.com © Daniel Fisher
  25. 25. lennybacon.com © Daniel Fisher
  26. 26. lennybacon.com © Daniel Fisher
  27. 27. lennybacon.com
  28. 28. lennybacon.com https://www.flickr.com/photos/hectoralejandro/3967217852
  29. 29. lennybacon.com
  30. 30. lennybacon.com API GET /api/builds POST /api/builds GET /api/builds/{slug} PUT /api/builds/{slug} PATCH /api/builds/{slug} DELETE /api/builds/{slug} BUILD /api/builds/{slug} GET /api/runningBuild/{id}
  31. 31. lennybacon.com
  32. 32. lennybacon.com Custom Verbs with Web API using System.Net; using System.Net.Http; using System.Web.Http; namespace WebApplication1.Controllers { public class BuildController : ApiController { [Route("api/builds/{id}")] [AcceptVerbsAttribute("GET", "BUILD")] public HttpResponseMessage Build(Guid value) { return new HttpResponseMessage(HttpStatusCode.OK); } } }
  33. 33. lennybacon.com https://www.flickr.com/photos/25726169@N03/8600834488
  34. 34. lennybacon.com HOSTING MSBUILD
  35. 35. lennybacon.com References • Microsoft.Build.dll • Microsoft.Build.Engine.dll • Microsoft.Build.Framework.dll
  36. 36. lennybacon.com Programmatically run a build public bool Run(string msBuildFile, Dictionary<string, string> properties) { var envVer = Environment.Version; var toolsVersion = envVer.Major + "." + envVer.MajorRevision; var project = new ProjectInstance(msBuildFile, properties, toolsVersion); var buildRequestData = new BuildRequestData(project, new string[] { }); var buildParameters = new BuildParameters { BuildThreadPriority = ThreadPriority.Highest, DefaultToolsVersion = toolsVersion, UseSynchronousLogging = true }; return BuildManager.DefaultBuildManager.Build( buildParameters, buildRequestData ).OverallResult == BuildResultCode.Success; }
  37. 37. lennybacon.com https://www.flickr.com/photos/jlauletta/14058076975
  38. 38. lennybacon.com APPDOMAIN ISOLATION
  39. 39. lennybacon.com Run in another AppDomain var appDomainSetup = new AppDomainSetup { PrivateBinPath = appPath, ApplicationBase = appPath }; var appDomain = AppDomain.CreateDomain( appName, new Evidence(AppDomain.CurrentDomain.Evidence), appDomainSetup ); var proxyObject = appDomain.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof (AppDomainManager).FullName ); AppDomain.Unload(appDomain);
  40. 40. lennybacon.com https://www.flickr.com/photos/ryan2point0/4986543660
  41. 41. lennybacon.com READ LENNYBACON.COM FOLLOW @LENNYBACON LINK LINKEDIN.COM/IN/LENNYBACON XING XING.COM/PROFILE/DANIEL_FISHER FRIEND FB.COM/DANIEL.FISHER.LENNYBACON MAIL DANIEL.FISHER@LENNYBACON.COM CALL +49 (176) 6159 8612
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×