JetBrains Space Help

.NET Core


  • You have a multiplatform .NET Core project.

Eligible images

Building, running tests, and publishing in a .NET Core desktop project

Currently, Space Automation does not provide any special API for working with .NET Core projects. This means, that you should run .NET Core builds by using the dotnet driver directly inside shell scripts.

The content of .space.kts may look like follows:

job(".NET Core desktop. Build, test, publish"){ container(""){ env["FEED_URL"] = "" shellScript { content = """ echo Run build... dotnet build echo Run tests... dotnet test ./MainTests/ echo Publish NuGet package... chmod +x ./ """ } } }

In more details:

  • env["FEED_URL"]: specifies a NuGet feed for publishing.

  • dotnet build and dotnet test: runs build and tests correspondingly.

  • ./ runs the publishing script. See details below.

The script authenticates in the NuGet feed and publishes the NuGet package:

#!/bin/sh echo "Configure credentials" dotnet nuget add source $FEED_URL -n space -u "%JB_SPACE_CLIENT_ID%" -p "%JB_SPACE_CLIENT_SECRET%" --store-password-in-clear-text VERSION=1.0.$JB_SPACE_EXECUTION_NUMBER echo "Publish nuget package" cd dotnet dotnet pack -p:PackageVersion=$VERSION -o ./ dotnet nuget push dotnet-sample.$VERSION.nupkg -s space

In more details:

  • $FEED_URL: specifies feed URL using the environment variable set in .space.kts.

  • $JB_SPACE_CLIENT_ID and $JB_SPACE_CLIENT_SECRET: environment variables that authenticate the Automation service in Space Packages.

  • VERSION="1.0.$JB_SPACE_EXECUTION_NUMBER": uses the $JB_SPACE_EXECUTION_NUMBER to specify the package version based on the script run number.

Last modified: 05 October 2020