Giter Club home page Giter Club logo

zipdotnettoolsincludeinvsix's Introduction

This project builds an MSBuild nuget package containing two tasks that will include zipped dotnet tools or nuget packages in a VSIX. The zip files may be generated on each build and this can be configured.

The nuget will add the necessary Target to the consuming vsix project and all that remains is to supply msbuild properties in the consuming vsix project file. If desired, the consuming project can create its own Target and use one of the two using tasks NugetNetToolMatchingPackageVersionZipIncludeInVsixToolTask NugetNetToolZipIncludeInVsixToolTask

The Target added is :

<Project>
  <Target Name="NugetNetToolZipIncludes" BeforeTargets="GetVsixSourceItems" Returns="@(Content)">
    <PropertyGroup>
      <NugetNetToolZipAssetSettingsPath Condition="'$(NugetNetToolZipAssetSettingsPath)'==''">$(MSBuildProjectFullPath)</NugetNetToolZipAssetSettingsPath>
    </PropertyGroup>
    <Message Text="Generating Zip Files For VSIX from settings $(NugetNetToolZipAssetSettingsPath)" />
    <NugetNetToolZipIncludeInVsixToolTask 
        VSIXSubPath="$(NugetNetToolZipVSIXSubPath)" 
        AssetFolder="$(NugetNetToolZipAssetFolder)" 
        AssetSettingsPath="$(NugetNetToolZipAssetSettingsPath)"
        ProjectFolder="$(MSBuildProjectDirectory)"
        UseExisting="$(NugetNetToolZipUseExisting)"
        Force="$(NugetNetToolZipForce)"
        >
            <Output TaskParameter="IncludedZipsInVsix" ItemName="Content" />
    </NugetNetToolZipIncludeInVsixToolTask>
    <NugetNetToolMatchingPackageVersionZipIncludeInVsixToolTask 
        VSIXSubPath="$(NugetNetToolZipVSIXSubPath)" 
        AssetFolder="$(NugetNetToolZipAssetFolder)" 
        AssetSettingsPath="$(NugetNetToolZipAssetSettingsPath)"
        ProjectFolder="$(MSBuildProjectDirectory)"
        UseExisting="$(NugetNetToolZipUseExisting)"
        Force="$(NugetNetToolZipForce)"
        >
            <Output TaskParameter="IncludedZipsInVsix" ItemName="Content" />
    </NugetNetToolMatchingPackageVersionZipIncludeInVsixToolTask>
  </Target>
</Project>

Both tasks are supplied the same arguments and if this is not suitable then create your own Target. The configuration for a task is done in an xml file - AssetSettingsPath. For the provided Target this defaults to the consuming project file. Each task expects a specific tag : NugetNetToolZipIncludes - NugetNetToolZipAsset NugetNetToolMatchingPackageVersionZipIncludeInVsixToolTask - NugetNetToolPackageVersionZipAsset

Here is the settings for the demo vsix - DemoVsixUsingTask

<AssetSettings>
  <NugetNetToolZipAsset>
    <ZipPrefix>coverlet.console</ZipPrefix>
    <NetToolName>coverlet.console</NetToolName>
  </NugetNetToolZipAsset>
  <NugetNetToolZipAsset>
    <ZipPrefix>microsoft.testplatform</ZipPrefix>
    <NugetPackageName>microsoft.testplatform</NugetPackageName>
  </NugetNetToolZipAsset>
  <NugetNetToolZipAsset>
    <ZipPrefix>openCover</ZipPrefix>
    <NugetPackageName>openCover</NugetPackageName>
  </NugetNetToolZipAsset>

  <NugetNetToolZipAsset>
    <ZipPrefix>coverlet.collector</ZipPrefix>
    <NugetPackageName>coverlet.collector</NugetPackageName>
    <VSIXSubPath>DifferentSubPath</VSIXSubPath>
    <AssetFolder>OtherZipAssets</AssetFolder>
  </NugetNetToolZipAsset>

  <NugetNetToolPackageVersionZipAsset>
    <ZipPrefix>reportGenerator</ZipPrefix>
    <NetToolName>dotnet-reportgenerator-globaltool</NetToolName>
    <ProjectFile>ReportGeneratorPlugins.aproj</ProjectFile>
    <PackageReference>ReportGenerator.Core</PackageReference>
  </NugetNetToolPackageVersionZipAsset>
</AssetSettings>

Common to each asset type : ZipPrefix - This will be the prefix of the generated zip. NetToolName or NugetPackageName - These are both the nuget package name. Use NetToolName when it needs to be installed with dotnet tool install.

Can be specified on the task for all assets or individually on an asset. AssetFolder - Specify the path to the folder where the zipped tools will be written to. This can be relative to the task ProjectFolder. VSIXSubPath - This determines the folder in the vsix where the zipped tool can be found. This is not required as will default to the name of the AssetFolder.

NugetNetToolZipAsset specific

IncludePreRelease AllowMajorUpdate

These are not specified in the example above and default to false. These affect the versions of the net tool or nuget package that can be installed and zipped. AllowMajorUpdate will be considered when there is an already generated zip in the AssetFolder. If false only available versions with the same major version will be considered. Set IncludePreRelease for pre release versions to be installed.

NugetNetToolPackageVersionZipAsset specific This zip asset type will only install a version that matches the designated PackageReference in the ProjectFile. The ProjectFile can be relative to ProjectFolder.

Task properties UseExisting and Force These task properties can be used to control the re-generation of the zip files. UseExisting will prevent a version update. Force will recreate the zip when there is no version update.

zipdotnettoolsincludeinvsix's People

Contributors

tonyhallett avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.