Skip to content

Commit 363f668

Browse files
authored
Move to .NET Standard 1.6 and dotnet CLI (#42)
1 parent c078d62 commit 363f668

File tree

5 files changed

+63
-65
lines changed

5 files changed

+63
-65
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# Build artefacts
2+
artefacts/
13
bazel-*
4+
**/bin/
25
**/obj/
36

7+
# IDE files
48
*~
59
.idea/
610
.vscode

Dockerfile

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
1-
FROM microsoft/dotnet:2.0-sdk
2-
3-
ENV MONO_VERSION 5.16.0.179
4-
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
5-
RUN echo "deb http://download.mono-project.com/repo/debian stretch/snapshots/$MONO_VERSION main" > /etc/apt/sources.list.d/mono-official.list \
6-
&& apt-get update \
7-
&& apt-get install -y mono-runtime \
8-
&& rm -rf /var/lib/apt/lists/* /tmp/*
9-
RUN apt-get update \
10-
&& apt-get install -y binutils curl mono-devel ca-certificates-mono fsharp mono-vbnc nuget referenceassemblies-pcl \
11-
&& rm -rf /var/lib/apt/lists/* /tmp/*
12-
13-
# Install OpenJDK-8
14-
RUN apt-get update && \
15-
apt-get install -y openjdk-8-jdk && \
16-
apt-get clean;
17-
18-
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
19-
RUN export JAVA_HOME
1+
# Adapted from: https://github.com/dotnet/dotnet-docker/blob/master/2.2/sdk/bionic/amd64/Dockerfile
2+
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-bionic
203

4+
## Improbable specific section
5+
# Fetch and set up the 'spatial' CLI.
216
RUN curl -L https://console.improbable.io/toolbelt/download/latest/linux -o /usr/bin/spatial
227
RUN chmod +x /usr/bin/spatial
238
RUN spatial update
249

10+
# Make the sources available in the container.
2511
WORKDIR /workspace
2612
COPY apis apis
2713
COPY examples examples
2814
COPY scripts scripts
2915

30-
RUN nuget restore examples/examples.sln
31-
16+
# Build the examples for use by scripts.
3217
ARG SDK_VERSION
33-
RUN msbuild examples/examples.sln /p:Configuration=Release /p:Version=$SDK_VERSION /t:Clean,Build -verbosity:minimal
18+
RUN dotnet build examples/examples.sln --configuration Release -p:Version=$SDK_VERSION
3419

20+
# Ensure authentication is available for the 'spatial' CLI and the Platform SDK.
3521
ARG IMPROBABLE_REFRESH_TOKEN
3622
ENV IMPROBABLE_REFRESH_TOKEN=$IMPROBABLE_REFRESH_TOKEN
3723
RUN mkdir -p $HOME/.improbable/oauth2 && echo $IMPROBABLE_REFRESH_TOKEN >> $HOME/.improbable/oauth2/oauth2_refresh_token

apis/apis.csproj

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,65 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<Authors>Improbable</Authors>
5+
<Copyright>Copyright 2019 Improbable</Copyright>
6+
<Description>Platform C# SDK that allows interacting with the SpatialOS Platform.</Description>
7+
<PackageTags>Platform SDK;Improbable;SpatialOS Platform</PackageTags>
8+
<PackageProjectUrl>https://github.com/spatialos/platform-sdk-csharp</PackageProjectUrl>
9+
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
10+
<RepositoryType>git</RepositoryType>
411
<AssemblyName>Improbable.SpatialOS.Platform</AssemblyName>
512
<RootNamespace>Improbable.SpatialOS.Platform</RootNamespace>
6-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
717
<Deterministic>true</Deterministic>
18+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
819
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
9-
<Description>Platform C# SDK that allows interacting with the SpatialOS Platform.</Description>
10-
<PackageTags>Platform SDK;Improbable;SpatialOS Platform</PackageTags>
11-
<Copyright>Copyright 2018 Improbable</Copyright>
12-
<Authors>Improbable</Authors>
13-
<TargetFrameworks>net451;netstandard1.5</TargetFrameworks>
20+
<TargetFrameworks>netstandard1.6</TargetFrameworks>
1421
</PropertyGroup>
1522

1623
<ItemGroup>
1724
<PackageReference Include="Google.LongRunning" Version="1.0.0" />
1825
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" />
26+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0-preview.2" />
1927
</ItemGroup>
2028

29+
<!-- For details on configuring ILRepack see https://www.phillipsj.net/posts/using-ilrepack-with-dotnet-core-sdk-and-dotnet-standard -->
2130
<Target Name="ILRepack" AfterTargets="Pack" Condition="'$(Configuration)' == 'Release' ">
2231
<PropertyGroup>
23-
<WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\net451</WorkingDirectory>
32+
<WorkingDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\netstandard1.6</WorkingDirectory>
2433
</PropertyGroup>
2534

2635
<ItemGroup>
27-
<InputAssemblies Include="Google.Protobuf.dll" />
28-
<InputAssemblies Include="System.Interactive.Async.dll" />
29-
<InputAssemblies Include="Newtonsoft.Json.dll" />
30-
<InputAssemblies Include="Grpc.Core.dll" />
31-
<InputAssemblies Include="Grpc.Auth.dll" />
32-
<InputAssemblies Include="Google.Protobuf.dll" />
33-
<InputAssemblies Include="Google.LongRunning.dll" />
34-
<InputAssemblies Include="Google.Apis.PlatformServices.dll" />
35-
<InputAssemblies Include="Google.Apis.dll" />
36-
<InputAssemblies Include="Google.Apis.Core.dll" />
37-
<InputAssemblies Include="Google.Apis.Auth.PlatformServices.dll" />
38-
<InputAssemblies Include="Google.Apis.Auth.dll" />
36+
<InputAssemblies Include="Improbable.SpatialOS.Platform.dll" />
37+
<InputAssemblies Include="Google.Api.CommonProtos.dll" />
3938
<InputAssemblies Include="Google.Api.Gax.Grpc.dll" />
4039
<InputAssemblies Include="Google.Api.Gax.dll" />
41-
<InputAssemblies Include="Google.Api.CommonProtos.dll" />
40+
<InputAssemblies Include="Google.Apis.Auth.PlatformServices.dll" />
41+
<InputAssemblies Include="Google.Apis.Auth.dll" />
42+
<InputAssemblies Include="Google.Apis.Core.dll" />
43+
<InputAssemblies Include="Google.Apis.dll" />
44+
<InputAssemblies Include="Google.LongRunning.dll" />
45+
<InputAssemblies Include="Google.Protobuf.dll" />
46+
<InputAssemblies Include="Google.Protobuf.dll" />
47+
<InputAssemblies Include="Grpc.Auth.dll" />
48+
<InputAssemblies Include="Grpc.Core.dll" />
49+
<InputAssemblies Include="Newtonsoft.Json.dll" />
50+
<InputAssemblies Include="System.Interactive.Async.dll" />
4251
</ItemGroup>
4352

4453
<!-- These DLLs are not internalised because they contains types that are user-facing. Internalising would mess up the namespace. -->
4554
<ItemGroup>
46-
<InternalizeExcludeAssemblies Include="^Google.Api.Gax" />
47-
<InternalizeExcludeAssemblies Include="^Google.Protobuf.WellKnownTypes" />
48-
<InternalizeExcludeAssemblies Include="^Grpc.Core" />
49-
<InternalizeExcludeAssemblies Include="^Google.LongRunning" />
55+
<InternalizeExcludeAssemblies Include="Improbable.SpatialOS.Platform" />
56+
<InternalizeExcludeAssemblies Include="Google.Api.Gax" />
57+
<InternalizeExcludeAssemblies Include="Google.LongRunning" />
58+
<InternalizeExcludeAssemblies Include="Google.Protobuf.WellKnownTypes" />
59+
<InternalizeExcludeAssemblies Include="Grpc.Core" />
5060
</ItemGroup>
5161

52-
<ILRepack Parallel="true" OutputType="$(OutputType)" MainAssembly="$(AssemblyName).dll" OutputAssembly="$(AssemblyName).dll" InputAssemblies="@(InputAssemblies)" InternalizeExcludeAssemblies="@(InternalizeExcludeAssemblies)" Internalize="true" WorkingDirectory="$(WorkingDirectory)" />
62+
<ILRepack Parallel="true" OutputType="$(OutputType)" MainAssembly="$(AssemblyName).dll" OutputAssembly="$(AssemblyName).dll" InputAssemblies="@(InputAssemblies)" InternalizeExcludeAssemblies="@(InternalizeExcludeAssemblies)" Internalize="true" WorkingDirectory="$(WorkingDirectory)" />
5363

5464
<ItemGroup>
5565
<AssembliesToDelete Include="$(WorkingDirectory)/%(InputAssemblies.Identity)" />

scripts/generateapis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd "${REPO_ROOT}"
77

88
source scripts/includes/bazel.sh
99

10-
generate_api() {
10+
function generate_api() {
1111
NAME="$1"
1212
VERSION="$2"
1313
PACKAGE="apis/${NAME}_${VERSION}"

scripts/release.sh

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ set -e -u -o pipefail
55
REPO_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
66
cd "${REPO_ROOT}"
77

8-
ARTEFACT_DIR="${REPO_ROOT}/artefacts"
9-
OUTPUT_DIR="${REPO_ROOT}/apis/bin/Release"
8+
PACKAGE_DIR="${REPO_ROOT}/artefacts"
9+
BIN_DIR="${REPO_ROOT}/apis/bin/Release"
10+
TARGET_FRAMEWORK="netstandard1.6"
1011

1112
if [[ -z "${SDK_VERSION+x}" ]]; then
1213
echo "Please set the SDK_VERSION environment variable to the correct version."
@@ -20,26 +21,23 @@ if [[ -z "${NUGET_API_KEY+x}" ]]; then
2021
fi
2122

2223
echo "--- Clearing artefacts from previous runs"
23-
rm -rf "${ARTEFACT_DIR}"
24-
mkdir -p "${ARTEFACT_DIR}"
24+
rm -rf "${PACKAGE_DIR}"
25+
mkdir -p "${PACKAGE_DIR}"
2526

2627
echo "--- Preparing artefacts for release"
27-
msbuild "${REPO_ROOT}/apis/apis.csproj" /t:Restore
28-
msbuild "${REPO_ROOT}/apis/apis.csproj" \
29-
/p:Configuration=Release \
30-
/p:Version="${SDK_VERSION}" \
31-
/t:Clean,Build \
32-
-verbosity:minimal
33-
34-
pushd "${OUTPUT_DIR}/net451"
35-
zip -r "${ARTEFACT_DIR}/${SDK_VERSION}-net451.zip" ./*
28+
dotnet build apis/apis.csproj --configuration Release --framework "${TARGET_FRAMEWORK}"
29+
dotnet pack apis/apis.csproj --no-build --configuration Release -p:"PackageVersion=${SDK_VERSION}"
30+
31+
pushd "${BIN_DIR}/${TARGET_FRAMEWORK}"
32+
zip -r "${PACKAGE_DIR}/${SDK_VERSION}.zip" ./*
3633
popd
3734

38-
cp "${OUTPUT_DIR}/Improbable.SpatialOS.Platform.${SDK_VERSION}.nupkg" "${ARTEFACT_DIR}"
35+
cp "${BIN_DIR}/Improbable.SpatialOS.Platform.${SDK_VERSION}.nupkg" "${PACKAGE_DIR}"
3936

4037
echo "--- Publishing to NuGet"
41-
nuget setApiKey "${NUGET_API_KEY}"
42-
nuget push "${ARTEFACT_DIR}/Improbable.SpatialOS.Platform.${SDK_VERSION}.nupkg" -Source https://api.nuget.org/v3/index.json
38+
dotnet nuget push "${PACKAGE_DIR}/Improbable.SpatialOS.Platform.${SDK_VERSION}.nupkg" \
39+
--source https://api.nuget.org/v3/index.json \
40+
--api-key "${NUGET_API_KEY}"
4341

4442
echo "--- Publishing to SpatialOS Package service"
45-
package_client publish platform_sdk csharp "${SDK_VERSION}" "${ARTEFACT_DIR}/${SDK_VERSION}-net451.zip"
43+
package_client publish platform_sdk csharp "${SDK_VERSION}" "${PACKAGE_DIR}/${SDK_VERSION}.zip"

0 commit comments

Comments
 (0)