Yarn.MSBuild 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Yarn.MSBuild --version 1.1.0
                    
NuGet\Install-Package Yarn.MSBuild -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Yarn.MSBuild" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Yarn.MSBuild" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Yarn.MSBuild" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Yarn.MSBuild --version 1.1.0
                    
#r "nuget: Yarn.MSBuild, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Yarn.MSBuild@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Yarn.MSBuild&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Yarn.MSBuild&version=1.1.0
                    
Install as a Cake Tool

Usage

This package installs yarn so you can use it from MSBuild without needing to install yarn globally.

YarnBuildCommand

If you set the YarnBuildCommand property, the command will run automatically in the "YarnBuild" target when you compile the application.

Example:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <YarnBuildCommand>run webpack</YarnBuildCommand>
    <YarnBuildCommand Condition="'$(Configuration)' == 'Release'">run webpack --env.prod</YarnBuildCommand>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Yarn.MSBuild" Version="1.1.0" />
  </ItemGroup>

</Project>
{
  "scripts": {
    "webpack": "./node_modules/.bin/webpack"
  },
  "dependencies": {
    "react": "^16.0.0"
  },
  "devDependencies": {
    "webpack": "^3.6.0"
  }
}

You can also chain of this target to run additional commands.

  <Target Name="YarnInstall" BeforeTargets="YarnBuild">
    <Yarn Command="install" Condition=" ! Exists('node_modules/')" />
  </Target>

Running yarn from a custom target

This package makes the Yarn task available for execution from your targets.

<Project>
  <Target Name="RunMyYarnCommands">
    
    <Yarn />

    
    <Yarn Command="run myscript" />

    
    <Yarn Command="upgrade" IgnoreExitCode="true" />

    
    <Yarn Command="run test" WorkingDirectory="wwwroot/" />

    
    <Yarn Command="run cmd" NodeJSExecutablePath="/opt/node8/bin/nodejs" />
  </Target>
</Project>

Additional options

Yarn inherits all properties available on ToolTask which allows further fine-tuning, such as controlling the logging-level of stderr and stdout and the process environment.

The Yarn task supports the following parameters

[Optional]
string Command                The arguments to pass to yarn.

[Optional]
string ExecutablePath         Where to find yarn (*nix) or yarn.cmd (Windows)

[Optional]
string NodeJsExecutablePath   Where to find node(js) (*nix) or node.cmd (Windows).
                              If not provided, node is expected to be in the PATH environment variable.

[Optional]
string WorkingDirectory       The directory in which to execute the yarn command

[Optional]
bool IgnoreExitCode           Don't create and error if the exit code is non-zero

Task outputs:

[Output]
int ExitCode                  Returns the exit code of the yarn process

About

This is not an official Yarn project. See LICENSE.txt and the Third Party Notice for more details.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETFramework 4.6

    • No dependencies.
  • .NETStandard 1.5

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Yarn.MSBuild:

Package Downloads
MintPlayer.AspNetCore.NodeServices

This package contains the abandoned node services.

Rixian.MSBuild.TailwindCSS

Adds build targets required to work with TailwindCSS in your project.

Blazor.BrowserExtension.Authentication

Adds MSAL authentication features to browser extensions written with Blazor.BrowserExtension.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Yarn.MSBuild:

Repository Stars
JeringTech/Javascript.NodeJS
Invoke Javascript in NodeJS, from C#
Version Downloads Last Updated
1.22.19 320,128 10/8/2022 1.22.19 is deprecated because it is no longer maintained.
1.22.17 104,981 10/23/2021
1.22.15 54,277 10/7/2021
1.22.10 109,501 10/4/2020
1.22.5 23,205 8/29/2020
1.22.4 118,028 3/10/2020
1.22.1 722 3/8/2020
1.22.0 137,809 2/6/2020
1.21.1 9,254 12/15/2019
1.16.0 57,988 6/21/2019
1.15.2 525,595 5/7/2019
1.13.0 61,806 2/22/2019
1.12.3 79,898 11/26/2018
1.7.0 15,902 6/26/2018
1.6.0 1,396 6/26/2018
1.5.2 6,135 5/1/2018
1.5.1 2,592 4/16/2018
1.3.4 2,989 3/4/2018
1.3.3 4,252 11/30/2017
1.3.2 1,356 11/29/2017
1.2.1 9,673 11/3/2017
1.2.0 1,661 10/28/2017
1.1.0 1,632 10/15/2017
1.0.2 2,423 10/15/2017
1.0.1 1,902 10/1/2017
1.0.0 1,730 9/10/2017
0.27.5 1,597 7/18/2017
0.24.6 2,487 5/31/2017
0.23.2 1,343 5/3/2017
0.21.3-beta 1,772 3/11/2017
0.21.3-alpha 1,752 3/4/2017

Changes in 1.1.0:
- Added an obsolete warning when YarnBuildCommand is empty. See https://github.com/natemcmaster/Yarn.MSBuild/issues/4 for details.
- Upgrade the bundled version of yarn to 1.1.0
   
- For more details on changes to yarn itself, see https://github.com/yarnpkg/yarn/releases/tag/v1.1.0