Giter Site home page Giter Site logo

github-actions-nx-dotnet's Introduction

Nx workspace using nx-dotnet. Contains a GitHub Actions CI workflow.

How to generate this workspace

Prerequisites

  • Node.js
  • PNPM
  • .NET CLI

Create Nx workspace

# Install the Nx workspace generator
pnpm install --global create-nx-workspace
# Generate a blank Nx workspace
pnpm init nx-workspace github-actions-nx-dotnet --preset=empty --pm=pnpm --npm-scope=dotnet --no-nx-cloud

Configure Nx workspace

# Install the "json" utility
npm install --global json
# Set the base branch to "main"
json -I -f nx.json -e "this.affected.defaultBase = 'main';"

Add .NET capability

# Install the Nx CLI
npm install --global @nrwl/cli
# Add nx-dotnet
pnpm add --save-dev @nx-dotnet/core
# Initialize nx-dotnet
nx generate @nx-dotnet/core:init

Configure Nx generator defaults

# Prefer nx-dotnet generators
json -I -f workspace.json -e "this.cli.defaultCollection = '@nx-dotnet/core';"
# Set defaults for nx-dotnet's "app" and "lib" generators
json -I -f workspace.json -e "this.generators = { '@nx-dotnet/core:app': { language: 'C#', tags: 'type:api', template: 'webapi', testTemplate: 'xunit' }, '@nx-dotnet/core:lib': { language: 'C#', template: 'classlib', testTemplate: 'xunit' } };"

Create web API project

# Generate web API and testing projects
nx generate app my-web-api
# Tag testing project with "type:test"
json -I -f nx.json -e "this.projects['my-web-api-test'].tags = ['type:test'].concat(this.projects['my-web-api-test'].tags.slice(1));"
# Set my-web-api as default Nx project
json -I -f workspace.json -e "this.defaultProject = 'my-web-api';"

Generate GitHub Actions CI workflow

# Install GitHub Actions .NET template
dotnet new -i TimHeuer.GitHubActions.Templates::1.0.5
# Generate GitHub Actions CI workflow
dotnet new workflow

Use Nx for Build job

  1. Remove the Restore step from .github/workflows/github-actions-nx-dotnet.yaml.
  2. Add Setup Node.js step after Setup .NET Core SDK step:
    - name: Setup Node.js
      uses: actions/setup-node@v1
      with:
        node-version: 14.x
    - name: Install PNPM
      run: npm install --global pnpm
    - name: Install Nx dependencies
      run: pnpm install
  3. Change the run command of the Build step to:
    pnpm build
    
  4. Change the run command of the Test step to:
    pnpm test
    

github-actions-nx-dotnet's People

Contributors

layzeedk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

joarkm1

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.