Skip to content

Commit

Permalink
Add support for netstandard20 (#89)
Browse files Browse the repository at this point in the history
* Rename NETSTANDARD1_3 to NETCOREAPP1_0 in tests
* Add netstandard2.0 and netcoreapp2.0 to target frameworks
* Build scripts for netstandard2.0
* Add netstandard2.0 to AppVeyor
  • Loading branch information
jariq committed Jun 11, 2018
1 parent 89632f1 commit 51d0a92
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 23 deletions.
5 changes: 4 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ environment:
- Platform: net40
- Platform: net45
- Platform: netstandard1.3
- Platform: netstandard2.0
- Platform: monoandroid2.3
- Platform: xamarinios1.0
install:
Expand All @@ -19,12 +20,14 @@ build_script:
- cmd: IF "%Platform%"=="net40" (cd build && build-net40.bat --with-tests)
- cmd: IF "%Platform%"=="net45" (cd build && build-net45.bat)
- cmd: IF "%Platform%"=="netstandard1.3" (cd build && build-netstandard1.3.bat --with-tests)
- cmd: IF "%Platform%"=="netstandard2.0" (cd build && build-netstandard2.0.bat --with-tests --skip-cleaning)
- cmd: IF "%Platform%"=="monoandroid2.3" (cd build && build-monoandroid2.3.bat)
- cmd: IF "%Platform%"=="xamarinios1.0" (cd build && build-xamarinios1.0.bat)
test_script:
- cmd: IF "%Platform%"=="net20" (nunit-console-x86 .\src\Pkcs11Interop\Pkcs11InteropTests\bin\Release\Pkcs11InteropTests.dll)
- cmd: IF "%Platform%"=="net40" (nunit-console .\src\Pkcs11Interop\Pkcs11InteropTests\bin\Release\Pkcs11InteropTests.dll)
- cmd: IF "%Platform%"=="netstandard1.3" (dotnet vstest .\src\Pkcs11Interop.NetStandard\Pkcs11Interop.DotNetCore.Tests\bin\Release\Pkcs11Interop.DotNetCore.Tests.dll)
- cmd: IF "%Platform%"=="netstandard1.3" (dotnet vstest .\src\Pkcs11Interop.NetStandard\Pkcs11Interop.DotNetCore.Tests\bin\Release\netcoreapp1.0\Pkcs11Interop.DotNetCore.Tests.dll --Framework:".NETCoreApp,Version=v1.0")
- cmd: IF "%Platform%"=="netstandard2.0" (dotnet vstest .\src\Pkcs11Interop.NetStandard\Pkcs11Interop.DotNetCore.Tests\bin\Release\netcoreapp2.0\Pkcs11Interop.DotNetCore.Tests.dll --Framework:".NETCoreApp,Version=v2.0")
artifacts:
- path: build/$(Platform)
name: $(Platform)
1 change: 1 addition & 0 deletions build/build-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ call build-net20.bat %arg1% || goto :error
call build-net40.bat %arg1% || goto :error
call build-net45.bat %arg1% || goto :error
call build-netstandard1.3.bat %arg1% || goto :error
call build-netstandard2.0.bat %arg1% || goto :error
call build-monoandroid2.3.bat %arg1% || goto :error
call build-xamarinios1.0.bat %arg1% || goto :error

Expand Down
21 changes: 14 additions & 7 deletions build/build-netstandard1.3.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
@rem Argument "--with-tests" forces the build of test project
@set arg1=%1

@rem Argument "--skip-cleaning" skips solution cleaning
@set arg2=%2

@rem Initialize build environment of Visual Studio 2017 Community/Professional/Enterprise
@set tools=
@set tmptools="c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsMSBuildCmd.bat"
Expand All @@ -18,28 +21,32 @@ call %tools%
@rem Delete output directory
rmdir /S /Q netstandard1.3

@rem Clean solution
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.NetStandard.sln ^
/p:Configuration=Release /p:Platform="Any CPU" /target:Clean || goto :error
@if not "%arg2%"=="--skip-cleaning" (
@rem Clean solution
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.NetStandard.sln ^
/p:Configuration=Release /p:Platform="Any CPU" /target:Clean || goto :error
)

@rem Restore dependencies for the solution
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.NetStandard.sln ^
/p:Configuration=Release /p:Platform="Any CPU" /target:Restore || goto :error

@rem Build Pkcs11Interop project
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\Pkcs11Interop.csproj ^
/p:Configuration=Release /p:Platform=AnyCPU /target:Build || goto :error
/p:Configuration=Release /p:Platform=AnyCPU /p:TargetFramework=netstandard1.3 ^
/target:Build || goto :error

@if "%arg1%"=="--with-tests" (
@rem Build Pkcs11Interop.DotNetCore.Tests project
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.DotNetCore.Tests\Pkcs11Interop.DotNetCore.Tests.csproj ^
/p:Configuration=Release /p:Platform=AnyCPU /target:Build || goto :error
/p:Configuration=Release /p:Platform=AnyCPU /p:TargetFramework=netcoreapp1.0 ^
/target:Build || goto :error
)

@rem Copy result to output directory
mkdir netstandard1.3 || goto :error
copy ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\bin\Release\Pkcs11Interop.dll netstandard1.3 || goto :error
copy ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\bin\Release\Pkcs11Interop.xml netstandard1.3 || goto :error
copy ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\bin\Release\netstandard1.3\Pkcs11Interop.dll netstandard1.3 || goto :error
copy ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\bin\Release\netstandard1.3\Pkcs11Interop.xml netstandard1.3 || goto :error

@echo *** BUILD NETSTANDARD1.3 SUCCESSFUL ***
@endlocal
Expand Down
58 changes: 58 additions & 0 deletions build/build-netstandard2.0.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@setlocal

@rem Argument "--with-tests" forces the build of test project
@set arg1=%1

@rem Argument "--skip-cleaning" skips solution cleaning
@set arg2=%2

@rem Initialize build environment of Visual Studio 2017 Community/Professional/Enterprise
@set tools=
@set tmptools="c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsMSBuildCmd.bat"
@if exist %tmptools% set tools=%tmptools%
@set tmptools="c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsMSBuildCmd.bat"
@if exist %tmptools% set tools=%tmptools%
@set tmptools="c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsMSBuildCmd.bat"
@if exist %tmptools% set tools=%tmptools%
@if not defined tools goto :error
call %tools%
@echo on

@rem Delete output directory
rmdir /S /Q netstandard2.0

@if not "%arg2%"=="--skip-cleaning" (
@rem Clean solution
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.NetStandard.sln ^
/p:Configuration=Release /p:Platform="Any CPU" /target:Clean || goto :error
)

@rem Restore dependencies for the solution
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.NetStandard.sln ^
/p:Configuration=Release /p:Platform="Any CPU" /target:Restore || goto :error

@rem Build Pkcs11Interop project
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\Pkcs11Interop.csproj ^
/p:Configuration=Release /p:Platform=AnyCPU /p:TargetFramework=netstandard2.0 ^
/target:Build || goto :error

@if "%arg1%"=="--with-tests" (
@rem Build Pkcs11Interop.DotNetCore.Tests project
msbuild ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop.DotNetCore.Tests\Pkcs11Interop.DotNetCore.Tests.csproj ^
/p:Configuration=Release /p:Platform=AnyCPU /p:TargetFramework=netcoreapp2.0 ^
/target:Build || goto :error
)

@rem Copy result to output directory
mkdir netstandard2.0 || goto :error
copy ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\bin\Release\netstandard2.0\Pkcs11Interop.dll netstandard2.0 || goto :error
copy ..\src\Pkcs11Interop.NetStandard\Pkcs11Interop\bin\Release\netstandard2.0\Pkcs11Interop.xml netstandard2.0 || goto :error

@echo *** BUILD NETSTANDARD2.0 SUCCESSFUL ***
@endlocal
@exit /b 0

:error
@echo *** BUILD NETSTANDARD2.0 FAILED ***
@endlocal
@exit /b 1
3 changes: 3 additions & 0 deletions build/build-nuget.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mkdir nuget\lib\net20 || goto :error
mkdir nuget\lib\net40 || goto :error
mkdir nuget\lib\net45 || goto :error
mkdir nuget\lib\netstandard1.3 || goto :error
mkdir nuget\lib\netstandard2.0 || goto :error
mkdir nuget\lib\monoandroid2.3 || goto :error
mkdir nuget\lib\xamarinios1.0 || goto :error

Expand All @@ -22,6 +23,8 @@ copy net45\Pkcs11Interop.dll nuget\lib\net45 || goto :error
copy net45\Pkcs11Interop.xml nuget\lib\net45 || goto :error
copy netstandard1.3\Pkcs11Interop.dll nuget\lib\netstandard1.3 || goto :error
copy netstandard1.3\Pkcs11Interop.xml nuget\lib\netstandard1.3 || goto :error
copy netstandard2.0\Pkcs11Interop.dll nuget\lib\netstandard2.0 || goto :error
copy netstandard2.0\Pkcs11Interop.xml nuget\lib\netstandard2.0 || goto :error
copy monoandroid2.3\Pkcs11Interop.dll nuget\lib\monoandroid2.3 || goto :error
copy monoandroid2.3\Pkcs11Interop.xml nuget\lib\monoandroid2.3 || goto :error
copy xamarinios1.0\Pkcs11Interop.dll nuget\lib\xamarinios1.0 || goto :error
Expand Down
2 changes: 2 additions & 0 deletions build/sign-all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ net20\Pkcs11Interop.dll ^
net40\Pkcs11Interop.dll ^
net45\Pkcs11Interop.dll ^
netstandard1.3\Pkcs11Interop.dll ^
netstandard2.0\Pkcs11Interop.dll ^
monoandroid2.3\Pkcs11Interop.dll ^
xamarinios1.0\Pkcs11Interop.dll || goto :error

Expand All @@ -23,6 +24,7 @@ net20\Pkcs11Interop.dll ^
net40\Pkcs11Interop.dll ^
net45\Pkcs11Interop.dll ^
netstandard1.3\Pkcs11Interop.dll ^
netstandard2.0\Pkcs11Interop.dll ^
monoandroid2.3\Pkcs11Interop.dll ^
xamarinios1.0\Pkcs11Interop.dll || goto :error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFrameworks>netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
<RootNamespace>Net.Pkcs11Interop.Tests</RootNamespace>
<DefineConstants>$(DefineConstants);NETSTANDARD1_3</DefineConstants>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<RootNamespace>Net.Pkcs11Interop.Mock</RootNamespace>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.3</TargetFramework>
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks>
<RootNamespace>Net.Pkcs11Interop</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
Expand Down Expand Up @@ -2254,4 +2254,5 @@
<Link>regeneratecode.sh</Link>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* Jaroslav IMRICH <[email protected]>
*/

#if (!NETSTANDARD1_3)
#if (!NETCOREAPP1_0)

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private List<ulong> GetManagedStructSizeList()
{
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_ATTRIBUTE))));
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_C_INITIALIZE_ARGS))));
#if NETSTANDARD1_3
#if NETCOREAPP1_0
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI40.CK_FUNCTION_LIST"))));
#else
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA40.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI40.CK_FUNCTION_LIST"))));
Expand Down Expand Up @@ -190,7 +190,7 @@ private List<ulong> GetManagedStructSizeList()
{
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_ATTRIBUTE))));
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_C_INITIALIZE_ARGS))));
#if NETSTANDARD1_3
#if NETCOREAPP1_0
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI41.CK_FUNCTION_LIST"))));
#else
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA41.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI41.CK_FUNCTION_LIST"))));
Expand Down Expand Up @@ -254,7 +254,7 @@ private List<ulong> GetManagedStructSizeList()
{
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_ATTRIBUTE))));
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_C_INITIALIZE_ARGS))));
#if NETSTANDARD1_3
#if NETCOREAPP1_0
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI80.CK_FUNCTION_LIST"))));
#else
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA80.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI80.CK_FUNCTION_LIST"))));
Expand Down Expand Up @@ -315,7 +315,7 @@ private List<ulong> GetManagedStructSizeList()
{
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_ATTRIBUTE))));
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_C_INITIALIZE_ARGS))));
#if NETSTANDARD1_3
#if NETCOREAPP1_0
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_INFO).GetTypeInfo().Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI81.CK_FUNCTION_LIST"))));
#else
sizeList.Add(Convert.ToUInt64(UnmanagedMemory.SizeOf(typeof(LLA81.CK_INFO).Assembly.GetType("Net.Pkcs11Interop.LowLevelAPI81.CK_FUNCTION_LIST"))));
Expand Down
2 changes: 1 addition & 1 deletion src/Pkcs11Interop/Pkcs11InteropTests/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private static string GetPkcs11MockLibraryPath()
return string.Empty;
#else

#if NETSTANDARD1_3
#if NETCOREAPP1_0
string path = typeof(Settings).GetTypeInfo().Assembly.CodeBase;
#else
string path = typeof(Settings).Assembly.CodeBase;
Expand Down

0 comments on commit 51d0a92

Please sign in to comment.