2015 techsummit web & cloud - gem, npm, bower, nuget, paket - päckchen hier, päckchen da

85
TechSummit: Web & Cloud Pure Technology. Päckchen hier, Päckchen da Daniel Fisher

Upload: daniel-fisher

Post on 19-Jul-2015

68 views

Category:

Internet


2 download

TRANSCRIPT

TechSummit: Web & Cloud Pure Technology.

Päckchen hier, Päckchen da

Daniel Fisher

• danielfisher.com

– Developer, Architect, Coach, Trainer

• lennybacon.com

– Blog

• Justcommunity.de

– Mit-Gründer und Vorstand

• nrwconf.de

– Mit-Gründer und Organisator

• twitter.com

– @lennybacon

Daniel Fisher

EFFICIENT COMMUNICATION…

Agenda

• Packagemanager?

• Gem

• NPM

• Bower

• NuGet

• Paket

• Chocolatey/OneGet

Once upon a time

In an age were we don't want to build everything on our own time shifted from building things to manage things…

• Search for {x} with your favorite search engine

• Download {x}

• Install {x}

• Fail because it requires {y}

Welcome to the Infinite loop!

https://www.flickr.com/photos/49889874@N05/4772680734/

Component based development

• If you build components packages can dramatically reduce time spend to• Check out from source control management

• Build *the* application

• Run tests

• …

Dependencies

• Setting up things• Frameworks

• Libraries

• Tools

• Infrastructure

http://maxogden.com/nested-dependencies.html

Dependency types

Dependency types

Flat

• Simple.

• Dependency conflicts

Nested

• Complicated

• No dependency conflicts

What is ruby?

• Developed by Yukihiro Matsumoto in the mid 90's• Object oriented

• Procedural

• Functional

• Dynamically typed

• Reflection

• Garbage Collection

• Since 2012 Standardized:ISO/IEC 30170

http://rubyinstaller.org/

What is RubyGems?

• Package manager for the Ruby programming language• Provides a standard format for distributing Ruby programs and libraries.

• Self-contained format called a "gem"

• Tool designed to easily manage the installation of gems

• Server for distributing them.

• RubyGems was created in about November 2003 and is now part of the standard library from Ruby version 1.9.

https://rubygems.org/

Validate GEM Installation

gem --version

Install a Package

gem install awesome_gem42

DEMO

*.gemspec file

Gem::Specification.new do |s|

s.name = %q{awesome_gem42}

s.version = "1.0.0"

s.authors = ["Daniel Fisher"]

s.date = %q{2015-05-06}

s.summary = %q{awesome_gem42 is the best}

s.files = [

"lib/awesome_gem42.rb"

]

s.require_paths = ["lib"]

end

Build and Publish Package

gem build awesome_gem42.gemspec

gem install awesome_gem42-1.0.0.gem

Using the Package

#ruby app.rb

require 'awesome_gem42'

AwesomeGem42::WhoIs.awesome?

What is npm?

• Node.js Package Manager• Open Source founded by Isaac Z. Schlueter

• The package manager for Javascript.

• Installed with node.js!

• Nested dependency trees

• Install modules used in a node.js environment, or development tools built using node.js such Karma, lint, minifiers and so on

https://www.npmjs.com/

Validate NPM Installation

npm --version

DEMO

Install a package

# Local Installation

npm install --save {package name}

# --save adds package to packages.json

# --save-dev adds package to packages.json

# Global Installation

npm install --global {package name}

npm install -g {package name}

Uninstall a package

# Local Installation

npm uninstall --save {package name}

# Global Installation

npm uninstall -g {package name}

Update all packages

# Local Installation

npm update

# Global Installation

npm install --global {package name}

npm install -g {package name}

Creating a NPM

npm init

Create a user account

npm adduser

Publish a package

npm publish

Unpublish a package

npm unpublish {package}@{version}

Package Intellisense

• https://visualstudiogallery.msdn.microsoft.com/65748cdb-4087-497e-a394-2e3449c8e61e

What is bower?

• Open Source created at twitter by

Jacob Thornton an Alex MacCaw

• Web sites are made of lots of things

• Frameworks

• Libraries

• Assets & Utilities

• Bower manages all these things for you.

• Frontend Dependency Management

• Flat dependency tree!

• Maintains a single version of a module

http://bower.io/

Install Bower

# Global Install

npm install --global bower

# Local Install

npm install --global bower

Validate Bower Installation

bower --version

DEMO

Install a package

bower install --save angular

# --save adds package to bower.json

Search available packages at:

https://bower.io/search/

List installed packages

bower list

Create a package

bower init

Link a repository

Publish a package

# Push sources to a git repository

bower register my-first-bower https://github.com/lennybacon/bower-samples

Git access token

• To remove a published package you need to prove you are the

owner of the Github repository…

Unpublish a package

# CURL*

curl -X DELETE "https://bower.herokuapp.com/packages/<package>?access_token=<token>"

# Powershell Alias

curl -Method DELETE -Uri "https://bower.herokuapp.com/packages/<package>?access_token=<token>"

*CURL for Windows: http://www.paehl.com/open_source/?CURL_7.41.0

Package Intellisense

• https://visualstudiogallery.msdn.microsoft.com/65748cdb-4087-497e-a394-2e3449c8e61e

What is NuGet

• Open Source Project started at Microsoft

by David Fowler and Davig Ebbo

• Intended to solve the issues related to management of 3rd party

assembly dependencies

• Microsoft Non .NET Framework stuff

• Open Source Libraries

• You own libraries!

http://nuget.org

What is NuGet

C#C#C#

WCF Data Services

Gallery Server

NuGet Core

VS Addin

ConsoleApp

MsBuild Tasks

DEMO

Visual Studio AddIn

• An embedded Powershell Console Window:

Also available in Visual Studio Express!!!

Visual Studio AddIn

• An embedded Powershell Console Window:

Powershell Commands

Get-Package -ListAvailable

Install-Package {packageid}

Remove-Package {packageid}

Console App

MsBuild Task<?xml version="1.0" encoding="utf-8"?><Project

DefaultTargets="PackageBuild"xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<UsingTask TaskName="NuPack.NuGet.NuPack" AssemblyFile="NuGet.MSBuild.dll" /> <ItemGroup>

<NuSpecFiles Include="..\*.*\*.nuspec" /></ItemGroup><Target Name="PackageBuild">

<NuGet.MSBuild.NuGetCondition="Exists(@(NuSpecFiles))"SpecFile="@(NuSpecFiles)"PackageDir="..\bin\"

/></Target>

</Project>

NuSpec

<?xml version="1.0"?><packagexmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">

<metadata><id>System.Web.Mvc</id><version>3.0</version><authors>Microsoft Corporation</authors><owners>Microsoft Corporation</owners><licenseUrl>http://www.asp.net/mvc</licenseUrl><projectUrl>http://www.asp.net/mvc</projectUrl><requireLicenseAcceptance>false</requireLicenseAcceptance><description>The Microsoft MVC Framework.</description><tags>ASP.NET MVC</tags>

</metadata></package>

NuSpec

<?xml version="1.0"?><packagexmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"><metadata><id>$id$</id><version>$version$</version><authors>$author$</authors><owners>$author$</owners><licenseUrl>http://www.asp.net/mvc</licenseUrl><projectUrl>http://www.asp.net/mvc</projectUrl><requireLicenseAcceptance>false</requireLicenseAcceptance><description>$description$</description><tags>ASP.NET MVC</tags>

</metadata></package>

[assembly: AssemblyTitle("MyLibrary")][assembly: AssemblyDescription("My cool library")][assembly: AssemblyCompany("Daniel Fisher")][assembly: AssemblyProduct("lennybacon's super tools")][assembly: AssemblyVersion("0.9.0.0")]

Dependencies

<dependencies>

<dependency id="EntityFramework" version="6.1.0" />

</dependencies>

Lowest possible below 3.0

<dependencies>

<dependency id="MyOtherPackage" version="[,3.0)" />

</dependencies>

Lowest possible between 2.0 and 3.0

<dependencies>

<dependency id="MyOtherPackage" version="[2.0,3.0)" />

</dependencies>

Latest and greatest

<dependencies>

<dependency id="MyOtherPackage" version="" />

</dependencies>

Console Commands

nuget pack {package.nuspec}

nuget Push {package.nupkg} {your_api_key} -src {server}

web.config.transform

<?xml version="1.0"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

<system.webServer><modules>

<add name="MyNuModule" type="…" xdt:Transform="Insert"

/>

<add name="MyNuModule" xdt:Transform="Remove" xdt:Locator="Match(name)"

/></modules>

</system.webServer></configuration>

MyFile.cs.pp

namespace $safeprojectname${

}

• http://docs.nuget.org/docs/creating-packages/configuration-file-and-source-code-transformations

• http://msdn.microsoft.com/en-us/library/eehb4faa(v=vs.80).aspx

Package Manager Powershell Scripts

• Init.ps1 runs the first time a package is installed in a solution.

• The script also runs every time the solution is opened.

• Install.ps1 runs when a package is installed in a project.

• Requires files in the content or lib directory for Install.ps1 to run.

• If your package also has ,an init.ps1 , install.ps1 runs after init.ps1.

• Uninstall.ps1 runs every time a package is uninstalled.

• NuGet_profile.ps1 runs when the Package Manager Console is

initialized – NOT part of the package!

Package Manager Powershell Scripts

• At the top of your file, add this line: param($installPath, $toolsPath, $package, $project)

• $installPath is the path to the installed package.

• $toolsPath is the path to the tools.

• $package is a reference to the package object.

• $project is a reference to the EnvDTE project object.

• This will be null in Init.ps1.

• When you are testing $project in the console while creating your

scripts, you can set it to:

$project = Get-Project

What is packet?

• Open Source started by Steffen Forkmann

• Paket is a dependency manager for .NET and Mono projects• NuGet packages

• Files in GitHub repositories

• It enables precise and predictable control over what packages the projects within your application reference.

• Global view on dependencies

• Versionsnumber not in the path

• plain text files and command line

https://github.com/fsprojects/Paket

DEMO

Install Paket

Install-Package Paket

The files

• paket.dependencies: Global definition of dependencies

• paket.lock: List of used versions for all dependencies

• paket.references: Dependency definition per project

Packet.dependencies

source https://nuget.org/api/v2

nuget Newtonsoft.Json // any version

nuget UnionArgParser >= 0.7 // x >= 0.7

nuget log4net ~> 1.2 // 1.2 <= x < 2

nuget NUnit prerelease // any version incl. prereleases

github forki/FsUnit FsUnit.fs

Packet.references

Newtonsoft.Json

UnionArgParser

NUnit

Installing packages

paket install

Check for updates

paket outdated

# update packages

paket update

Check for updates

paket outdated

Restore

paket restore

Convert from Nuget

paket convert-from-nugget

paket simplify

What is Chocolatey

• Open Source started by Rob Reynolds

• Chocolatey is a package manager for Windows• like apt-get or yum but for Windows

• Quickly instal applications and tools

• Built on the NuGet infrastructure

• Using PowerShell

https://github.com/chocolatey

DEMO

Install Chocolatey

iex (new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'

))

Installing Packages

choco install {package}

Installing a developer box

choco install dotnet4.5

choco install python

choco install easy.install

choco install ruby

choco install java

choco install java.jdk

choco install php

choco install git

choco install poshgit

choco install hg

choco install sourcetree

choco install svn

choco install firefox

choco install chrome

choco install 7zip.install

choco install nodejs.install

choco install mysql.workbench

choco install logparser

choco install octopusdeploy.tentacle

choco install markdownpad2

choco install nuget.commandline

choco install dropbox

choco install fiddler

choco install cmder

choco install visualstudio2013ultimate

choco install resharper

choco install sublimetext3

choco install webpi

choco install lockhunter

choco install sqlserver2014express

choco install postgresql

choco install mongodb

choco install mysql

choco install sqllite

choco install rabbitmq

choco install redis

choco install linqpad

choco install Microsoft-build-tools

choco install docker

choco install wixtoolset

OneGet

READ LENNYBACON.COM

FOLLOW @LENNYBACON

LINK LINKEDIN.COM/IN/LENNYBACON

XING XING.COM/PROFILE/DANIEL_FISHER

FRIEND FB.COM/DANIEL.FISHER.LENNYBACON

MAIL [email protected]

CALL +49 (176) 6159 8612

Wir freuen uns über Ihr Feedback!

http://aka.ms/TechSummitFB