Skip to content

Commit

Permalink
Add Publish target to publish C++ NuGet packages (#3479)
Browse files Browse the repository at this point in the history
  • Loading branch information
pepone authored Feb 3, 2025
1 parent f1072c9 commit 0f3e5d1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
10 changes: 8 additions & 2 deletions cpp/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,17 @@ When compiling Ice programs, you must pass the location of the `<prefix>/include
You can create a NuGet package with the following command:

```shell
msbuild msbuild\ice.proj /t:NuGetPack /p:BuildAllConfigurations=yes
msbuild msbuild\ice.proj /t:Pack /p:BuildAllConfigurations=yes
```

This creates `zeroc.ice.v143\zeroc.ice.v143.nupkg`.

You can publish the package to your local `global-packages` source with the following command:

```shell
msbuild msbuild/ice.proj /t:Publish
```

## Cleaning the source build on Linux or macOS

Running `make clean` will remove the binaries created for the default configuration and platform.
Expand Down Expand Up @@ -278,7 +284,7 @@ python3 allTests.py
### iOS

The test scripts require Ice for Python. You can build Ice for Python from the [python](../python) folder of this source
distribution, or install the Python `zeroc-ice` pip package, using the following command:
distribution, or install the Python `zeroc-ice` pip package, using the following command:

```shell
python3 -m pip install zeroc-ice
Expand Down
17 changes: 15 additions & 2 deletions cpp/msbuild/ice.proj
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
</Target>

<!-- Create nuget packages -->
<Target Name="NuGetPack"
DependsOnTargets="BuildDist">
<Target Name="Pack" DependsOnTargets="BuildDist">

<RemoveDir Directories="zeroc.ice.$(DefaultPlatformToolset)" />

Expand Down Expand Up @@ -182,4 +181,18 @@
<Exec Command="$(NuGetExe) pack -NoPackageAnalysis -NonInteractive"
WorkingDirectory="zeroc.ice.$(DefaultPlatformToolset)"/>
</Target>

<Target Name="Publish" DependsOnTargets="Pack">
<Exec Command="$(NuGetExe) locals global-packages -list" ConsoleToMSBuild="true" EchoOff="yes">
<Output TaskParameter="ConsoleOutput" PropertyName="NuGetGlobalPackages" />
</Exec>
<PropertyGroup>
<NuGetGlobalPackages>$(NuGetGlobalPackages.TrimStart('info : '))</NuGetGlobalPackages>
<NuGetGlobalPackages>$(NuGetGlobalPackages.TrimStart('global-packages: '))</NuGetGlobalPackages>
</PropertyGroup>

<RemoveDir Directories="$(NuGetGlobalPackages)\zeroc.ice.$(DefaultPlatformToolset)\$(IceJSONVersion)"
Condition="Exists('$(NuGetGlobalPackages)\zeroc.ice.$(DefaultPlatformToolset)\$(IceJSONVersion)')"/>
<Exec Command="$(NuGetExe) push $(MSBuildThisFileDirectory)zeroc.ice.$(DefaultPlatformToolset)\zeroc.ice.$(DefaultPlatformToolset).$(IceJSONVersion).nupkg -source $(NuGetGlobalPackages)" />
</Target>
</Project>

0 comments on commit 0f3e5d1

Please sign in to comment.