Creating CppREST SDK NuGet Package Instruction
The following instructions include two parts: preparing binaries and creating NuGet package.The preparing binaries steps are requires, you must follow exactly.
In the creaing NuGet package steps, you can choose either manually creating or using CoApp tool.
Preparing Binaries
- Make sure includes in repository are up to date matching for release.
- Copy the signed dlls under the \Casablanca\Release\nuget\Binaries.
- Copy the libs and pdbs into \Casablanca\Release\nuget\Binaries.
- Copy the \Casablanca\Release\include to \Casablanca\Release\nuget\include.
- Running rename_stripped_pdbs.ps1 script to replace full symbols with stripped ones.
- Update the init.ps1 to correct version. (e.g. change cpprest2_1.natvis to cpprest2_2.natvis).
Manually Creating NuGet Package
- Update the cpprestsdk.nuspec to the correct version number.
<version>2.2.0</version> ... <file src="Binaries\Win32\Debug\cpprest120d_2_2.dll" target="\build\native\bin\Win32\v120\Debug\Desktop\cpprest120d_2_2.dll" />
- Update the cpprestsdk.targets with the correct version number.
<CppRestSDKVersionMajor>2</CppRestSDKVersionMajor> <CppRestSDKVersionMinor>2</CppRestSDKVersionMinor> <CppRestSDKVersionRevision>0</CppRestSDKVersionRevision>
- If you need to add more targeting platforms( e.g. phone8.1), you need to update the .target file in following 3 steps.
- Add a new ItemDefinitionGroup element with correct condition and new “.lib” file.
<ItemDefinitionGroup Label="ARM and v120_wp81 and Debug and Phone8" Condition="'$(Platform.ToLower())' == 'arm' And '$(PlatformToolset.ToLower())' == 'v120_wp81' And ( $(Configuration.ToLower().IndexOf('debug')) == -1 ) > <Link> <AdditionalDependencies>$(MSBuildThisFileDirectory)lib\ARM\v120_wp81\Debug\Phone8\cpprest120_wp81_$(CppRestSDKVersionFileSuffix).lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup>
- Add anew SetEnv element with correct condition and the new path value to register the .dll path
<SetEnv Condition="'$(Platform.ToLower())' == 'win32' And '$(PlatformToolset.ToLower())' == 'v120_wp81' And ( $(Configuration.ToLower().IndexOf('debug')) == -1 )Name="PATH" Prefix="true" Value="$(MSBuildThisFileDirectory)bin\Win32\v120_wp81\Release\Phone8"> <Output TaskParameter="OutputEnvironmentVariable" PropertyName="PATH" /> </SetEnv>
- Add a new CopyToOutput element. For windows phone8.1, we do not want to include our CppREST SDK binaries as content, so we do not need to provide the DeploymentContent element.
<CopyToOutput Include="$(MSBuildThisFileDirectory)bin\ARM\v120_wp81\Release\Phone8\cpprest120_wp81_$(CppRestSDKVersionFileSuffix).dll" /> <CopyToOutput Include="$(MSBuildThisFileDirectory)bin\ARM\v120_wp81\Release\Phone8\cpprest120_wp81_$(CppRestSDKVersionFileSuffix).pdb" />
- After finished all these steps, you can download the Nuget command utility, run the command under the directory where this cpprestsdk.nuspec created.
nuget.exe pack
Creating NuGet Package with CoApp
CoApp is a set of open source tools for building C/C++ NuGet packages for Windows. You can download and install the CoApp from here.- Open and edit the cpprestsdk.autopkg file to update the new version, release notes, description.
VER_WUNDERSCORE = 2_2;
- If you need to add more targeting platform, all you need is simply add a new item list:
[arm,v120_wp81,debug,phone8] { bin: ${ARM_DLLS}cpprest120d_wp81_${VER_WUNDERSCORE}.dll; symbols: ${BIN_DIR}ARM\Debug\cpprest120d_wp81_${VER_WUNDERSCORE}.pdb; lib:${BIN_DIR}ARM\Debug\cpprest120d_wp81_${VER_WUNDERSCORE}.lib; }
In this new item list, arm is for the target platform, v120_wp81 is the toolset, phone8 is the output directory. After creating the nuget package, you will find the binaries under packages\cpprestsdk.2.2.0\build\native\bin\arm\v120_wp81\Debug\Phone8.
- Make sure you have the latest CoApp tools, running following command from PowerShell:
Update-CoAppTools -KillPowershells
- Due to issues of CoApp tools, you need to modify the file C:\Program Files (x86)\Outercurve Foundation\Modules\CoApp\etc\PackageScriptTemplate.autopkg. Find the "bin += {" section and add the following line:
bin += { #add-each-file : { --> Items.ReferenceCopyLocalPaths; Items.CopyToOutput;
- Create new package by running:
Write-NuGetPackage .\cpprestsdk.autopkg -SplitThreshold 1000
- CoApp does not officially support phone8.1 yet, after creating the NuGet package, you need to install the Nuget package explorer. Open the cpprestsdk.2.2.0.nupkg with this explorer, edit the build\native\cpprestsdk.targets. Find the ItemGroup Label="ARM and v120_wp81 and Release and Phone8", remove or comment out the Deployment element.