Skip to content

Commit

Permalink
.NET framework copy targets and smoke test (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz committed Jul 17, 2023
1 parent 9cb71af commit 945f058
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 5 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,18 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3

- name: Add dependency on local package
run: dotnet add tests/Temporalio.SmokeTest package Temporalio -s "${{ github.workspace }}/nuget-package;https://api.nuget.org/v3/index.json" --prerelease

- name: Run smoke test
run: dotnet run --project tests/Temporalio.SmokeTest
run: |
dotnet add tests/Temporalio.SmokeTest package Temporalio -s "${{ github.workspace }}/nuget-package;https://api.nuget.org/v3/index.json" --prerelease
dotnet run --project tests/Temporalio.SmokeTest
- name: Setup msbuild (Windows only)
if: ${{ matrix.os == 'windows-latest' }}
uses: microsoft/setup-msbuild@v1.1

- name: Run .NET framework smoke test (Windows only)
if: ${{ matrix.os == 'windows-latest' }}
run: |
dotnet add tests/Temporalio.SmokeTestDotNetFramework package Temporalio -s "${{ github.workspace }}/nuget-package;https://api.nuget.org/v3/index.json" --prerelease
msbuild tests/Temporalio.SmokeTestDotNetFramework -t:restore,build -p:Platform=x64
tests/Temporalio.SmokeTestDotNetFramework/bin/x64/Debug/Temporalio.SmokeTestDotNetFramework.exe
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ CLI:

dotnet add package Temporalio --prerelease

If you are using .NET framework, you have to explicitly set the platform to `x64` or `arm64`, `AnyCPU` will not choose
the proper library.

**NOTE: This README is for the current branch and not necessarily what's released on NuGet.**

### Implementing a Workflow and Activity
Expand Down
6 changes: 5 additions & 1 deletion src/Temporalio/Temporalio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@
</ItemGroup>
</Target>

<!-- Pack the README -->
<!-- Pack the README and targets file -->
<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="\" />
<Content Include="build/net462/Temporalio.targets">
<PackagePath>build/net462/</PackagePath>
<Pack>true</Pack>
</Content>
</ItemGroup>

<!-- Pack the runtime if BridgeLibraryRoot property set -->
Expand Down
31 changes: 31 additions & 0 deletions src/Temporalio/build/net462/Temporalio.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\linux-$(Platform)\native\libtemporal_sdk_bridge.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libtemporal_sdk_bridge.so</Link>
<Visible>false</Visible>
<NuGetPackageId>Temporalio</NuGetPackageId>
</Content>
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\osx-$(Platform)\native\libtemporal_sdk_bridge.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>libtemporal_sdk_bridge.dylib</Link>
<Visible>false</Visible>
<NuGetPackageId>Temporalio</NuGetPackageId>
</Content>
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-$(Platform)\native\temporal_sdk_bridge.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>temporal_sdk_bridge.dll</Link>
<Visible>false</Visible>
<NuGetPackageId>Temporalio</NuGetPackageId>
</Content>
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions tests/Temporalio.SmokeTestDotNetFramework/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[*.cs]

##### Temporal additions ######

# Please keep in alphabetical order by field.

# Don't need to mark smoke test classes static
dotnet_diagnostic.CA1812.severity = none

# Don't need to mark smoke test classes sealed
dotnet_diagnostic.CA1852.severity = none

# ConfigureAwait not needed in tests
dotnet_diagnostic.CA2007.severity = none

# Don't need to doc smoke test classes
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1600.severity = none

###############################
6 changes: 6 additions & 0 deletions tests/Temporalio.SmokeTestDotNetFramework/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
</startup>
</configuration>
25 changes: 25 additions & 0 deletions tests/Temporalio.SmokeTestDotNetFramework/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Threading.Tasks;
using Temporalio.Api.WorkflowService.V1;
using Temporalio.Testing;

namespace Temporalio.SmokeTestDotNetFramework
{
internal class Program
{
public static async Task Main()
{
var env = await WorkflowEnvironment.StartLocalAsync();
try
{
Console.WriteLine(
"System info: {0}",
await env.Client.Connection.WorkflowService.GetSystemInfoAsync(new GetSystemInfoRequest()));
}
finally
{
await env.ShutdownAsync();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Temporalio.SmokeTestDotNetFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Temporalio.SmokeTestDotNetFramework")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("76900724-edd1-4404-831e-66c94c7d478e")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{76900724-EDD1-4404-831E-66C94C7D478E}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Temporalio.SmokeTestDotNetFramework</RootNamespace>
<AssemblyName>Temporalio.SmokeTestDotNetFramework</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<Nullable>disable</Nullable>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>

<!--
Intentionally not added, expected to be added by caller/CI
<ItemGroup>
<PackageReference Include="Temporalio" Version="some-version" />
</ItemGroup>
-->

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 945f058

Please sign in to comment.