SlideShare a Scribd company logo
Turning my Reports into a NuGet Package.
In my previous post on creating an EPiServer Usage Report I had some additional tasks to
complete. These tasks involved turning the reports into a nugget package to allow anybody
to use them on their site.
NuGet is a free and open-source package manager for the Microsoft development platform
(previously known as NuPack). Since its introduction in 2010, NuGet has evolved into a large
ecosystem of tools and services.
Refactoring
Before I can create the package I need to I need to perform
some simple refactoring and by tackling this first I reduce
error that will find in my finial NuGet Package.
Firstly, I Renamed the UsageReports folder to
CSharpBrew.UsageReports and updated the namespaces
to match. This will ensure we don’t deploy on top of existing.
Underneath I create a new folder called ‘Pages’ and moved
all the ASPX files into it. Next comes the ‘ViewModels’ folder
to hold the presentation models. Finally, I create a simple
class ‘UsageReportsService.cs’ to hold all the reporting logic.
By moving this logic into a separate class I aid future
development and gain the ability to write unit tests against
this logic.
Create a new Project.
As well as creating a new class library project in visual studio I also chose to create it in a
different location from the website. This was done to allow me to version control it separately.
Now I simple moved the folder contents of CSharpBrew.UsageReports in our new project.
Then I checked the namespace to remove any prefix, i.e. AllowDemoKit.
Now, If try to rebuild this project, I receive a large number of errors about missing assembly
references.
This is expected and easily fixed and simply involves installing the CMS UI Core package,
from the EPiServer Nuget Feed.
However, as I to target as broadest range of web sites as possible I need to install a lower
version.
This can be done via the nugget package manager, or by searching the EPiServer Nuget
repository and running the correct Package Manager Command.
PM> Install-Package EPiServer.CMS.Core -Version 7.6.0
Uploading to GitHub
Now that I’ve a working project I wish to upload it to GitHub, so it’s available to everybody.
This is done via a new public repository that also includes the Apache License. To ensure
that I will still get some credit for my work and prevent some misuse.
Once I committed my work it’s available for anyone to download. http://bit.ly/1PiwIIi
Adding Packager
Now I need to package my project. To do this I’m using a Visual Studio extension called
NuGet Packager. A simple project template for creating packages within Visual Studio. To
install Packager we can search for in inside Tools -> Extensions and Updates dialog or
through the Visual Studio Gallery.
This allows me to create a new project with the postfix of Packager, which will contains the
package.nuspec. This is where my project is declared and the majority of the content is self-
explanatory; however, two section are importance; the dependencies and files.
Dependencies are there to ensure the correct DLL’s are installed and prevent installation on
incompatible projects i.e. we need EPiServer CMS 7.6 or greater. The version can be a
singular of range. For instance, "1.2.10" works with one version, whereas version="[7.6.0,9)"
is a range from 7.6 up to and including version 9.
<dependencies>
<group targetFramework="net40">
<dependency id="log4net" version="1.2.10" />
<dependency id="EPiServer.CMS.Core" version="[7.6.0,9)" />
</group>
</dependencies>
The files section contains all the content, we need to deploy and elements used to configure
the deployment.
The first two sections copyies the (aspx files and web.config) into the content folder which
will be deployed into the modules folder. The next I copy the Dll into libnet45, to allows them
to be referenced by Visual Studio.
Also as Packager is a separate project I will need use a relative path to the original project.
I.e. by prefixing “..CSharpBrew.UsageReports”.
<files>
<file src="..CSharpBrew.UsageReportsPages*.aspx"
target="contentmodulesCSharpBrew.UsageReportsPages" />
<file src="..CSharpBrew.UsageReportsweb.config"
target="contentmodulesCSharpBrew.UsageReports" />
<file
src="..CSharpBrew.UsageReportsPagesbinReleaseCSharpBrew.UsageReport
s.dll" target="libnet45" />
<file src="web.config.*.xdt" target="Content" />
</files>
The finial node copies two xdt files, which are used to transform the web.config, via a
Transformation Syntax. This Syntax consists of two attributes that can be attached to an Xml
element. xdt:Locator is an locate the correct node which will be used with xdt:Transform
to insert, update or delete an element or attribute.
web.config.install.xdt will transform the web.config when it’s added to project.
<episerver.shell>
<publicModules>
<add name="CSharpBrew.UsageReports"
xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)">
<assemblies>
<add assembly="CSharpBrew.UsageReports" />
</assemblies>
</add>
</publicModules>
</episerver.shell>
web.config.uninstall.xdt will transform the web.config when it’s removed.
<episerver.shell>
<publicModules>
<add name="CSharpBrew.UsageReports" xdt:Transform="Remove"
xdt:Locator="Match(name)"/>
</publicModules>
</episerver.shell>
Now when the Packager project is build it also produce the package; which is just a zip file
with the extension of nupkg.
Installing the Package
Now I have a package I need to it into my website project. As I wish to test my package
before its released I will install it from a local folder before it’s released.
Usefully the nuget.config supports multiple package sources, so I can deploy locally and
to www.nuget.org as well.
<configuration>
<packageSources>
<add key="NuGet official package source"
value="https://www.nuget.org" />
<add key="Local package Source" value="C:ProjectsPackages" />
</packageSources>
<configuration>
To add additional package sources I open the Tools menu, clicked Options to go to Visual
Studio settings. Next I expanded the NuGet Package Manger section and clicked Package
Sources.
Finally, I clicked the green plus symbol and entered the name as Local package Source
and location as C:ProjectsPackages
When I’m happy and have completed my testing I can update the nuget.config to now
include an apikey to allow me to deploy to www.nuget.org.
<configuration>
<apikeys>
<add key="https://www.nuget.org" value="" />
</apikeys>
<packageSources>
To Locate the apikey I first logged into NuGet and then clicked on account to see my key.
And that’s it all I now need to do is rebuild and the script will automatically publish to
NuGet.
Finial Thoughts
Now I have a usable NuGet packages my next steps is to turn these reports into something
more useful.
NuGet is a incredibly useful tool for integrating third library’s into your projects, but it’s also
extremely useful for creating internal packages for private consummation and I have in
several company creating nugget packages to allow reuse of work.
Finally, i’ve also made some change to NuGetPackage.ps1, for versioning and configuration
support, please fill free to checkout my source.
Ad

More Related Content

What's hot (19)

Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
Mukta Aphale
 
Build using jenkins on rtc repository
Build using jenkins on rtc repositoryBuild using jenkins on rtc repository
Build using jenkins on rtc repository
Ankit Vashistha
 
Jupyter notebook 20200728
Jupyter notebook 20200728Jupyter notebook 20200728
Jupyter notebook 20200728
Haim Michael
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
Justin James
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
backend
backendbackend
backend
tutorialsruby
 
Access google command list from the command line
Access google command list from the command lineAccess google command list from the command line
Access google command list from the command line
Ethan Lorance
 
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.ppt
Promet Source
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
Larry Cai
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Git
dirtytactics
 
A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.
Subramanyam Vemala
 
hw1a
hw1ahw1a
hw1a
tutorialsruby
 
YouDrup_in_Drupal
YouDrup_in_DrupalYouDrup_in_Drupal
YouDrup_in_Drupal
tutorialsruby
 
Cloud and Ubiquitous Computing manual
Cloud and Ubiquitous Computing manual Cloud and Ubiquitous Computing manual
Cloud and Ubiquitous Computing manual
Sonali Parab
 
Easy install
Easy installEasy install
Easy install
Lee Dohyup
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
Soshi Nemoto
 
Kubernetes rolling back
Kubernetes rolling backKubernetes rolling back
Kubernetes rolling back
linuxdady
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Using Kubernetes for Continuous Integration and Continuous DeliveryUsing Kubernetes for Continuous Integration and Continuous Delivery
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Dockerfiles building docker images automatically v (workdir, env, add, and ...
Dockerfiles   building docker images automatically v (workdir, env, add, and ...Dockerfiles   building docker images automatically v (workdir, env, add, and ...
Dockerfiles building docker images automatically v (workdir, env, add, and ...
ansonjonel
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
Mukta Aphale
 
Build using jenkins on rtc repository
Build using jenkins on rtc repositoryBuild using jenkins on rtc repository
Build using jenkins on rtc repository
Ankit Vashistha
 
Jupyter notebook 20200728
Jupyter notebook 20200728Jupyter notebook 20200728
Jupyter notebook 20200728
Haim Michael
 
Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
Justin James
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
Access google command list from the command line
Access google command list from the command lineAccess google command list from the command line
Access google command list from the command line
Ethan Lorance
 
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.ppt
Promet Source
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
Larry Cai
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Git
dirtytactics
 
A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.
Subramanyam Vemala
 
Cloud and Ubiquitous Computing manual
Cloud and Ubiquitous Computing manual Cloud and Ubiquitous Computing manual
Cloud and Ubiquitous Computing manual
Sonali Parab
 
Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)Big query - Command line tools and Tips - (MOSG)
Big query - Command line tools and Tips - (MOSG)
Soshi Nemoto
 
Kubernetes rolling back
Kubernetes rolling backKubernetes rolling back
Kubernetes rolling back
linuxdady
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Using Kubernetes for Continuous Integration and Continuous DeliveryUsing Kubernetes for Continuous Integration and Continuous Delivery
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Dockerfiles building docker images automatically v (workdir, env, add, and ...
Dockerfiles   building docker images automatically v (workdir, env, add, and ...Dockerfiles   building docker images automatically v (workdir, env, add, and ...
Dockerfiles building docker images automatically v (workdir, env, add, and ...
ansonjonel
 

Similar to Creating an nuget package for EPiServer (20)

Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for Enterprises
J S Jodha
 
nuxt-en.pdf
nuxt-en.pdfnuxt-en.pdf
nuxt-en.pdf
ssuser65180a
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
Perrin Harkins
 
A Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptxA Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptx
MusaBadaru
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+
Ajay Rathore
 
Introduction to package manager
Introduction to package managerIntroduction to package manager
Introduction to package manager
yashobantabai
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
Katy Slemon
 
A guide to EPiServer CMS Scheduled Job
A guide to EPiServer CMS Scheduled JobA guide to EPiServer CMS Scheduled Job
A guide to EPiServer CMS Scheduled Job
Paul Graham
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
Andrey Karpov
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
NodeXperts
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf
BOSC Tech Labs
 
Developing eXtensions for HUE
Developing eXtensions for HUEDeveloping eXtensions for HUE
Developing eXtensions for HUE
Maksym Doroshenko
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
Steve Keener
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
European Collaboration Summit
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
Andrey Karpov
 
Azure DevOps Extensions
Azure DevOps ExtensionsAzure DevOps Extensions
Azure DevOps Extensions
Christian Waha
 
Flask
FlaskFlask
Flask
Mamta Kumari
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
David Gibbons
 
Setting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntuSetting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntu
kesavan N B
 
Chocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pieChocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pie
Justin James
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for Enterprises
J S Jodha
 
Care and feeding notes
Care and feeding notesCare and feeding notes
Care and feeding notes
Perrin Harkins
 
A Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptxA Presentation of Dash Enterprise and Its Interface.pptx
A Presentation of Dash Enterprise and Its Interface.pptx
MusaBadaru
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+
Ajay Rathore
 
Introduction to package manager
Introduction to package managerIntroduction to package manager
Introduction to package manager
yashobantabai
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
Katy Slemon
 
A guide to EPiServer CMS Scheduled Job
A guide to EPiServer CMS Scheduled JobA guide to EPiServer CMS Scheduled Job
A guide to EPiServer CMS Scheduled Job
Paul Graham
 
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
You can now use PVS-Studio with Visual Studio absent; just give it the prepro...
Andrey Karpov
 
Improving build solutions dependency management with webpack
Improving build solutions  dependency management with webpackImproving build solutions  dependency management with webpack
Improving build solutions dependency management with webpack
NodeXperts
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf
BOSC Tech Labs
 
Developing eXtensions for HUE
Developing eXtensions for HUEDeveloping eXtensions for HUE
Developing eXtensions for HUE
Maksym Doroshenko
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
Steve Keener
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
European Collaboration Summit
 
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOpsPVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
PVS-Studio Is Now in Chocolatey: Checking Chocolatey under Azure DevOps
Andrey Karpov
 
Azure DevOps Extensions
Azure DevOps ExtensionsAzure DevOps Extensions
Azure DevOps Extensions
Christian Waha
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
David Gibbons
 
Setting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntuSetting up the hyperledger composer in ubuntu
Setting up the hyperledger composer in ubuntu
kesavan N B
 
Chocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pieChocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pie
Justin James
 
Ad

More from Paul Graham (7)

Publising a nuget package
Publising a nuget packagePublising a nuget package
Publising a nuget package
Paul Graham
 
EPiServer report generation
EPiServer report generationEPiServer report generation
EPiServer report generation
Paul Graham
 
Adding disqus to ghost blog
Adding disqus to ghost blogAdding disqus to ghost blog
Adding disqus to ghost blog
Paul Graham
 
Creating EPiServer Usage Reports
Creating EPiServer Usage ReportsCreating EPiServer Usage Reports
Creating EPiServer Usage Reports
Paul Graham
 
C# 6.0
C# 6.0C# 6.0
C# 6.0
Paul Graham
 
Entity framework (EF) 7
Entity framework (EF) 7Entity framework (EF) 7
Entity framework (EF) 7
Paul Graham
 
Code syntax highlighting in ghost
Code syntax highlighting in ghostCode syntax highlighting in ghost
Code syntax highlighting in ghost
Paul Graham
 
Publising a nuget package
Publising a nuget packagePublising a nuget package
Publising a nuget package
Paul Graham
 
EPiServer report generation
EPiServer report generationEPiServer report generation
EPiServer report generation
Paul Graham
 
Adding disqus to ghost blog
Adding disqus to ghost blogAdding disqus to ghost blog
Adding disqus to ghost blog
Paul Graham
 
Creating EPiServer Usage Reports
Creating EPiServer Usage ReportsCreating EPiServer Usage Reports
Creating EPiServer Usage Reports
Paul Graham
 
Entity framework (EF) 7
Entity framework (EF) 7Entity framework (EF) 7
Entity framework (EF) 7
Paul Graham
 
Code syntax highlighting in ghost
Code syntax highlighting in ghostCode syntax highlighting in ghost
Code syntax highlighting in ghost
Paul Graham
 
Ad

Recently uploaded (20)

Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 

Creating an nuget package for EPiServer

  • 1. Turning my Reports into a NuGet Package. In my previous post on creating an EPiServer Usage Report I had some additional tasks to complete. These tasks involved turning the reports into a nugget package to allow anybody to use them on their site. NuGet is a free and open-source package manager for the Microsoft development platform (previously known as NuPack). Since its introduction in 2010, NuGet has evolved into a large ecosystem of tools and services.
  • 2. Refactoring Before I can create the package I need to I need to perform some simple refactoring and by tackling this first I reduce error that will find in my finial NuGet Package. Firstly, I Renamed the UsageReports folder to CSharpBrew.UsageReports and updated the namespaces to match. This will ensure we don’t deploy on top of existing. Underneath I create a new folder called ‘Pages’ and moved all the ASPX files into it. Next comes the ‘ViewModels’ folder to hold the presentation models. Finally, I create a simple class ‘UsageReportsService.cs’ to hold all the reporting logic. By moving this logic into a separate class I aid future development and gain the ability to write unit tests against this logic.
  • 3. Create a new Project. As well as creating a new class library project in visual studio I also chose to create it in a different location from the website. This was done to allow me to version control it separately. Now I simple moved the folder contents of CSharpBrew.UsageReports in our new project. Then I checked the namespace to remove any prefix, i.e. AllowDemoKit. Now, If try to rebuild this project, I receive a large number of errors about missing assembly references. This is expected and easily fixed and simply involves installing the CMS UI Core package, from the EPiServer Nuget Feed.
  • 4. However, as I to target as broadest range of web sites as possible I need to install a lower version. This can be done via the nugget package manager, or by searching the EPiServer Nuget repository and running the correct Package Manager Command. PM> Install-Package EPiServer.CMS.Core -Version 7.6.0
  • 5. Uploading to GitHub Now that I’ve a working project I wish to upload it to GitHub, so it’s available to everybody. This is done via a new public repository that also includes the Apache License. To ensure that I will still get some credit for my work and prevent some misuse. Once I committed my work it’s available for anyone to download. http://bit.ly/1PiwIIi
  • 6. Adding Packager Now I need to package my project. To do this I’m using a Visual Studio extension called NuGet Packager. A simple project template for creating packages within Visual Studio. To install Packager we can search for in inside Tools -> Extensions and Updates dialog or through the Visual Studio Gallery. This allows me to create a new project with the postfix of Packager, which will contains the package.nuspec. This is where my project is declared and the majority of the content is self- explanatory; however, two section are importance; the dependencies and files. Dependencies are there to ensure the correct DLL’s are installed and prevent installation on incompatible projects i.e. we need EPiServer CMS 7.6 or greater. The version can be a singular of range. For instance, "1.2.10" works with one version, whereas version="[7.6.0,9)" is a range from 7.6 up to and including version 9. <dependencies> <group targetFramework="net40"> <dependency id="log4net" version="1.2.10" /> <dependency id="EPiServer.CMS.Core" version="[7.6.0,9)" /> </group> </dependencies>
  • 7. The files section contains all the content, we need to deploy and elements used to configure the deployment. The first two sections copyies the (aspx files and web.config) into the content folder which will be deployed into the modules folder. The next I copy the Dll into libnet45, to allows them to be referenced by Visual Studio. Also as Packager is a separate project I will need use a relative path to the original project. I.e. by prefixing “..CSharpBrew.UsageReports”. <files> <file src="..CSharpBrew.UsageReportsPages*.aspx" target="contentmodulesCSharpBrew.UsageReportsPages" /> <file src="..CSharpBrew.UsageReportsweb.config" target="contentmodulesCSharpBrew.UsageReports" /> <file src="..CSharpBrew.UsageReportsPagesbinReleaseCSharpBrew.UsageReport s.dll" target="libnet45" /> <file src="web.config.*.xdt" target="Content" /> </files> The finial node copies two xdt files, which are used to transform the web.config, via a Transformation Syntax. This Syntax consists of two attributes that can be attached to an Xml element. xdt:Locator is an locate the correct node which will be used with xdt:Transform to insert, update or delete an element or attribute.
  • 8. web.config.install.xdt will transform the web.config when it’s added to project. <episerver.shell> <publicModules> <add name="CSharpBrew.UsageReports" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)"> <assemblies> <add assembly="CSharpBrew.UsageReports" /> </assemblies> </add> </publicModules> </episerver.shell> web.config.uninstall.xdt will transform the web.config when it’s removed. <episerver.shell> <publicModules> <add name="CSharpBrew.UsageReports" xdt:Transform="Remove" xdt:Locator="Match(name)"/> </publicModules> </episerver.shell> Now when the Packager project is build it also produce the package; which is just a zip file with the extension of nupkg.
  • 9. Installing the Package Now I have a package I need to it into my website project. As I wish to test my package before its released I will install it from a local folder before it’s released. Usefully the nuget.config supports multiple package sources, so I can deploy locally and to www.nuget.org as well. <configuration> <packageSources> <add key="NuGet official package source" value="https://www.nuget.org" /> <add key="Local package Source" value="C:ProjectsPackages" /> </packageSources> <configuration> To add additional package sources I open the Tools menu, clicked Options to go to Visual Studio settings. Next I expanded the NuGet Package Manger section and clicked Package Sources. Finally, I clicked the green plus symbol and entered the name as Local package Source and location as C:ProjectsPackages
  • 10. When I’m happy and have completed my testing I can update the nuget.config to now include an apikey to allow me to deploy to www.nuget.org. <configuration> <apikeys> <add key="https://www.nuget.org" value="" /> </apikeys> <packageSources>
  • 11. To Locate the apikey I first logged into NuGet and then clicked on account to see my key. And that’s it all I now need to do is rebuild and the script will automatically publish to NuGet.
  • 12. Finial Thoughts Now I have a usable NuGet packages my next steps is to turn these reports into something more useful. NuGet is a incredibly useful tool for integrating third library’s into your projects, but it’s also extremely useful for creating internal packages for private consummation and I have in several company creating nugget packages to allow reuse of work. Finally, i’ve also made some change to NuGetPackage.ps1, for versioning and configuration support, please fill free to checkout my source.