Martin Ullrich @dasMulli MSBuild Martin Ullrich @dasMulli.

Slides:



Advertisements
Similar presentations
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
Advertisements

What’s New in ASP.NET 5 and Visual Studio 2015 SPENCER SCHNEIDENBACH GADELLNET CONSULTING SERVICES.
ASP.NET vNEXT & development tools Marco De
POSTSHARP TECHNOLOGIES Better software through simpler code.
Scalable Game Development William Roberts Senior Game Engineer
Tips & Tricks: Extending MSBuild with Tasks, Loggers, and Targets Faisal Mohamood TLNL01 Program Manager - MSBuild Microsoft Corporation.
MSBuild: Architecting a Customized Build System Rajeev Goel, TLN402 Software Development Engineer MSBuild Microsoft Corporation.
Presentation Name / 1 Visual C++ Builds and External Dependencies NAME.
MSBuild Unveiled Peter Schneider MVP Visual Developer – Visual C# MCT, MCSD.NET, MCAD.NET, MCDBA
ASP.NET 5 Unleashed Javier Lozano
0 Developing for Windows 10 Tony Champion Champion DS.
ASP.NET Core* 1.0 The Future of Web Apps Shahed Chowdhuri
Enterprise Library 3.0 Memi Lavi Solution Architect Microsoft Consulting Services Guy Burstein Senior Consultant Advantech – Microsoft Division.
C Copyright © 2009, Oracle. All rights reserved. Using SQL Developer.
Toni Petrina Microsoft MVP for C# Ekobit d.o.o. Controlling and extending development environment.
Why Learn Android? Largest installation base of any operating system Over 20,000 Android devices exist Businesses will likely move more to device-based.
Advanced BIML topics Be a W.I.S.E. A.S.S. Me ! Self-employed BI consultant Author Trainer MCT
ASP.NET Core* in 2017 The Future of Web Apps Shahed Chowdhuri
Intro To Android Programming
Top 10 Entity Framework Features Every Developer Should Know
DevOps with ASP.NET Core and Entity Framework Core
12/29/2017 2:33 PM © Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN.
From SharePoint to Office 365 Development
Real world Windows Phone development
Build Fundamentals and Continuous Integration
Agenda:- DevOps Tools Chef Jenkins Puppet Apache Ant Apache Maven Logstash Docker New Relic Gradle Git.
Introducing the Windows Mobile development
Mobile Device Development
Open-O Integration Project Introduction
Stress Free Deployments with Octopus Deploy
The Simple Corpus Tool Martin Weisser Research Center for Linguistics & Applied Linguistics Guangdong University of Foreign Studies
Getting started with .NET Core
DotnetConf 9/10/2018 7:49 PM © 2016 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE.
Tulika Chaudharie / Harikharan Krishnaraju
Introduction to ASP.NET 2.0
Automate Custom Solutions Deployment on Office 365 and Azure
Android Studio, Android System Basics and Git
Designing For Testability
The Modern ASP.NET Tech Stack!
PYTHON: AN INTRODUCTION
Brian Leonard ブライアン レオナルド
ASP.NET Core* 1.0 The Future of Web Apps Shahed Chowdhuri
Windows Azure Jason Olson, Program Manager 4-142
Lean .NET stack for building modern web apps
DNN Connect 2017 Microsoft Keynote
Microsoft Virtual Academy
1.1. .NET architectural components and .NET Core
MVC in ASP.NET Core: The new kid on the block
Instructor: Prasun Dewan (FB 150,
How to automate software with
William Roberts Ryan Hipple
Microsoft Ignite NZ October 2016 SKYCITY, Auckland
Learn. Imagine. Build. .NET Conf
SPA Revolution with WebAssembly and Blazor Rainer Stropek | software
Using Visual Studio and VS Code for Embedded C/C++ Development
Introduction to SharePoint Framework
Visual Studio Code + Ionic
What’s new in ASP.NET Core and Entity Framework 2.2 (Preview 3)
SSDT and Database Project Basics
TechEd /3/ :48 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Eagle: Maturation and Evolution
Martin A. NuGet Deep Dive Martin A.
SharePoint Workflow: Taking the Manual Out of Your Process
Windows Forms in Visual Studio 2005: An in-depth look at key features
Introduction to ASP.NET Parts 1 & 2
#01# ASP.NET Core Overview Design by: TEDU Trainer: Bach Ngoc Toan
Concepts in ASP.NET Core App
MS Confidential : SharePoint 2010 Developer Workshop (Beta1)
ASP.NET Core 2.0 The Future of Web Apps Shahed Chowdhuri
What’s ASP.NET 5 and Why? Scott Hunter | Director of Program Management Scott Hanselman | Principal Program Manager.
Presentation transcript:

Martin Ullrich @dasMulli MSBuild Martin Ullrich @dasMulli

Hi, I’m Martin @dasMulli Martin Ullrich Martin Andreas Ullrich Senior Consultant at Tieto Austria Software Engineer C#/.NET, iOS (ObjC/Swift), Java, Frontends, … Cares about Build Automation, CI / CD Somewhat active on .NET Core GitHub Repos Learned MSBuild in 2016 @dasMulli Martin Ullrich

Agenda Overview and Context How it works Diagnosing Issues Demos - Tips and Tricks Questions, Questions, Questions

Goals Never use „xcopy“ in build events again Have an easier time navigating .csproj files https://github.com/dasMulli/CSProjDemos/blob/master/02_CopyFiles/CopyFilesDemo/CopyFilesDemo.csproj

MSBuild: “The 2003 Format”

Project.json 😢 { "version": "1.2.3", "dependencies": { "Newtonsoft.Json": "10.0.1” }, "frameworks": { "netcoreapp1.0": { "Microsoft.NetCore.App": { "type": "platform", "version": "1.0.0" }

The Reality

Why didn’t project.json save us all? .csproj too complicated back then Chicken or the egg problem How do I migrate 100 projects? .NET Standard projects need to be referenced by existing projects. “.xproj” Visual Studio and existing tools are built around MSBuild Limited extensibility

Other dotnet CLI issues Re-implemented many MSBuild features Incremental compilation Configuration management NuGet packages containing MSBuild logic no longer work Missing Features / Edge cases / Bugs Visual Studio: UI over project.json OmniSharp & others: separate handling

Build Systems ”flexible” DSL Code Gulp Grunt project.json Gradle MSBuild Maven Cake

New Console App – Classic csproj

New Console App – “SDK-style” csproj

MSBuild 15 Open Source 🎉 - https://github.com/Microsoft/msbuild Runs on .NET Core and Mono Replaces xbuild on Mono Syntactic sugar SDKs, Metadata Attributes for Items, … Automatically discovered files Directory.Build.(props|targets|rsp) Performance Improvements More Features & Functionality on each minor release

Tooling - IDEs Visual Studio OmniSharp Visual Studio for Mac Rider Visual Studio Code Atom, Vim, … Visual Studio for Mac Rider 3rd party tools E.g. dotnet-outdated

Visual Studio: Project Systems

Visual Studio: Project Systems csproj.dll, msvbproj.dll Native, COM-based Single-threaded, bound to UI Thread “the new project system” – dotnet/project-system Managed Multi-threaded, scalable, responsive Developed on GitHub Some Features may or may not work yet

MSBuild 101

MSBuild 101 XML Format Definitions + Logic "Variables”, “Lists” Can look like a DSL "Variables”, “Lists” Conditions, Loops  Control Flow Is it a programming language?

MSBuild 101: Code Demo

Project Files Any XML file can be an MSBuild project .props / .targets are only a loose convention .props = Beginning of files / contain defaults .targets = End of files / build logic MSBuild command line looks for *.*proj files by default

Properties vs. Items Key-Value Pair “Variable” Single Value Environment Variables are Properties Well-Known Properties Global Properties Can override definition in project file Collections “Lists” Identity + Metadata Duplicates are possible May represent files on disk  Glob Patterns Used for Batching “Loops”, “Group By” Item Definition  Default Metadata

Properties $(MyProperty)

Items @(MyItems)  MyItemA;MyItemB @(MyItems->’%(Identity).old’)  MyItemA.old;MyItemB.old @(Person->’%(LastName)’, ‘ - ‘)  Ullrich – Doe

Warning: Static Evaluation All project XML is scanned before targets run “Static Evaluation” Order is important here: Properties and Imports Item definitions Items Allows for a few ”default item” features EnableDefaultItems EnableDefaultCompileItems …

Property Functions MSBuild allows calling .NET code Built-In functions Some select .NET Types <NewGuid>$([System.Guid]::NewGuid())</NewGuid> <Sum>$([MSBuild]::Add($(CommitCount), 2))</Sum> <IsBeta>$(Version.EndsWith(‘beta’))</IsBeta>

Targets Contain actual build logic Only run once Contains tasks Property and Item Groups are “intrinsic tasks” Targets can have dependencies  Graph Targets can define Inputs and Outputs Enables incremental builds (skipping targets) Newest timestamps of Inputs and Outputs are compared

Project SDKs Automatic Imports SdkResolvers try to find the SDK Name or Name/Version On disk or NuGet On disk: .NET Core CLIs with compatible MSBuild versions “Sdk\Sdk.props” and “Sdk\Sdk.targets” will be imported automatically Import tag also supports Sdk attribute

Diagnostics?

So you just hit a build error… Logs are your best friend Verbose logs: msbuild -flp:verbosity=diag Binary logs (15.3+): msbuild -bl Embeds project file contents Super helpful for looking at issues without the source Structured Log Viewer http://msbuildlog.com

Project File Demos

More Demos?

Demo Menu Publish for multiple target frameworks Using ”MSBuild Scripts” for your CI pipeline 1 Directory, multiple SDK-style csproj files Include referenced Projects in NuGet package Ship your build logic as NuGet packages + Create your own “Project SDK” Create inline MSBuild Tasks with RolsynCodeTaskFactory Creating a cross-platform MSBuild Task https://github.com/dasMulli/AdvancedMSBuildDemos

Questions?

Useful Links https://github.com/Microsoft/msbuild https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild MSBuild reserved and well-known properties MSBuild well-known item metadata Common MSBuild project properties Common MSBuild project items Additions to the csproj format for .NET Core