> ## Content Index
> Fetch the complete content index at: https://codetraveler.io/llms.txt
> Use this file to discover other available public pages before exploring further.

# Using Preview Versions of .NET Core with App Center Build
- URL: https://codetraveler.io/2019/08/23/using-preview-versions-of-net-core-with-app-center-build/
- Published: 2019-08-23T17:02:50.000Z
- Updated: 2019-08-28T17:30:36.000Z
- Description: App Center is a great tool for building, testing, releasing and monitoring apps, but what if we want to use a preview version of .NET Core?
- Author: Brandon Minnick
- Tags: appcenter, appcenter build, build, .NET, net, .NET Core, core, .NET Core 3.0, Xamarin, Xamarin.iOS, Xamarin.Android, Preview

[App Center](https://appcenter.ms/?WT.mc%5Fid=netcoreappcenterbuild-codetraveler-bramin&ref=codetraveler.io) is a great tool for building, testing, releasing and monitoring apps, but what if we want to use a preview version of .NET Core? 

Today, App Center Build doesn't support the preview versions .NET Core. This means that when I use .NET Core 3.0, my build fails with this error:

```
The current .NET SDK does not support targeting .NET Core 3.0
```

(Here's the complete error message)

```
##[section]Starting: Restore Nuget
==============================================================================
Task         : Command Line
Description  : Run a command line with arguments
Version      : 1.1.3
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613735)
==============================================================================
[command]/bin/bash -c /usr/bin/find . -name '*.sln' -type f -print0 | /usr/bin/xargs -0 grep -l 'MondayPundayApp.Droid.csproj' | /usr/bin/xargs -I '{}' nuget restore '{}' -DisableParallelProcessing
MSBuild auto-detection: using msbuild version '15.0' from '/Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/15.0/bin'.
/Users/vsts/hostedtoolcache/dotnet/sdk/2.2.300/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. [/Users/vsts/agent/2.155.1/work/1/s/Src/MondayPundayApp.UnitTests/MondayPundayApp.UnitTests.csproj]

##[error]/bin/bash failed with return code: 1
##[error]/bin/bash failed with error: /bin/bash failed with return code: 1
```

To work-around this problem, let's write a script that installs the version of .NET Core we need.

## 1\. Write a Post-Clone Script

App Center Build allows us to write a [bash script that runs after the build machine has finished cloning our repo](https://docs.microsoft.com/appcenter/build/custom/scripts?WT.mc%5Fid=netcoreappcenterbuild-codetraveler-bramin&ref=codetraveler.io#post-clone), called a `Post-Clone` script:

1\. In the same directory as the Android `.csproj`, create a new file called `appcenter-post-clone.sh`

> Place the scripts with the format specified below next to the project-level (.xcodeproj, .csproj, .sln or package.json) file

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-10.55.00-AM.png)

2\. (Repeat for iOS) In the same directory as the iOS `.csproj`, create a new file called `appcenter-post-clone.sh`

3\. Open both `appcenter-post-clone.sh` files

4\. In `appcenter-post-clone.sh`, copy the following Bash script:

```bash
wget https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --version $netcoreversion --install-dir "$AGENT_TOOLSDIRECTORY/dotnet"
```

5\. Commit the new `appcenter-post-clone.sh` files and push the updates to your remote git repository

## 2\. Update App Center Build Settings

1\. In [App Center](https://appcenter.ms/?WT.mc%5Fid=netcoreappcenterbuild-codetraveler-bramin&ref=codetraveler.io), navigate to your app's **Build** configuration

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-10.10.48-AM.png)

2\. On the **Build Branches** page, select the **Settings Gear** next to the branch you'd like to configure

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-9.43.54-AM.png)

3\. In the **Build Configuration** menu, select **More Options**

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-9.44.05-AM.png)

4\. In the **More Options** section of the **Build Configuration** menu, ensure `Post-Clone` is listed as a build script

**Note**: If `Post-Clone` is not listed, ensure that you've saved `appcenter-post-clone.sh` its [project-level directory](https://docs.microsoft.com/appcenter/build/custom/scripts/index?WT.mc%5Fid=netcoreappcenterbuild-codetraveler-bramin&ref=codetraveler.io) and have commited the file to your remote git repository

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-9.44.14-AM.png)

5\. In the **Build Configuration** menu, in the **Environment Variables** section, add the following key-value par:

**Note**: You can specify any version of .NET Core as the **Value**

```
| Name           | Value                   |
| netcoreversion | 3.0.100-preview8-013656 |
```

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-9.45.11-AM.png)

6\. In the **Build Configuration** menu, select **Save & Build**

![](https://storage.ghost.io/c/dc/c2/dcc2e43e-24f8-46bb-a899-9c446f3ef794/content/images/2019/08/Screen-Shot-2019-08-23-at-9.45.20-AM.png)