Skip Ribbon Commands
Skip to main content

Software Development Blog

Jun 21
Nuget Extension: Automatically copying package contents to projects output folder

In a project we are dynamically loading assemblies with MEF, we use Nuget to package the parts of our application.

This results in the scenario that we have references added to assemblies which are not needed to be referenced.

I've created the Nuget package Baseclass.Contrib.Nuget.Output to add the missing feature to nuget. It adds the possibility to have a folder called "output" in the root of the nuget package and automatically copies its contents to the projects output path.

Open source: https://github.com/baseclass/Contrib.Nuget

Example:

  1. Create a TestPackage (Tipp: Use PackageExplorer to create it) which has a test file in the output folder and depends on Baseclass.Contrib.Nuget.Output.

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

    <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">

    <metadata>

    <id>TestPackage</id>

    <version>1.0.0</version>

    <authors>Daniel</authors>

    <requireLicenseAcceptance>false</requireLicenseAcceptance>

    <description>My package description.</description>

    <dependencies>

    <dependency id="Baseclass.Contrib.Nuget.Output" />

    </dependencies>

    </metadata>

    <files>

    <file src="output\test.txt" target="output\test.txt" />

    </files>

    </package>

    and save it in C:\temp\temppackagesRepository.

  2. Create a new project in VisualStudio
  3. Add C:\temp\temppackagesRepository to the PackageSources (Options > Package Manager > Package Sources)
  4. Install the TestPackage
  5. Build the project.
  6. Take a look at debug folder: 

    output.PNG

     
comments powered by Disqus

 ‭(Hidden)‬ Blogtools