Skip to content

Commit

Permalink
Merge pull request #4840 from danilo-delbusso/private/danilod/sdk
Browse files Browse the repository at this point in the history
CP-40404: Add C# NuGet specs in its csproj and Move C# SDK samples to .NET 6.0
  • Loading branch information
danilo-delbusso authored Dec 7, 2022
2 parents f00d920 + 4d21f73 commit 4adbf80
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 265 deletions.
53 changes: 53 additions & 0 deletions ocaml/sdk-gen/csharp/README-NuGet.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
XenServer.NET
=============

XenServer.NET is a complete SDK for XenServer, exposing the XenServer
API as .NET classes. It is written in C#.

XenServer.NET includes a class for every API class, and a method for each API
call, so API documentation and examples written for other languages will apply
equally well to .NET. In particular, the SDK Guide and the Management API Guide
are ideal for developers wishing to use XenServer.NET.

XenServer.NET is free software. You can redistribute and modify it under the
terms of the BSD 2-Clause license. See LICENSE.txt for details.

This library is accompanied by pedagogical examples. These do not form
part of this library, and are licensed for redistribution and modification
under the BSD 2-Clause license.


Reference
---------

For XenServer documentation see https://docs.citrix.com/en-us/citrix-hypervisor/

The XenServer Management API Reference is available at
https://developer-docs.citrix.com/projects/citrix-hypervisor-management-api/en/latest/

The XenServer Software Development Kit Guide is available at
https://developer-docs.citrix.com/projects/citrix-hypervisor-sdk/en/latest/

For community content, blogs, and downloads, visit
https://www.citrix.com/community/citrix-developer/

To network with other developers using XenServer visit
https://discussions.citrix.com/forum/101-hypervisor-formerly-xenserver/


Prerequisites
-------------

This library requires .NET Standard 2.0.


Dependencies
------------

XenServer.NET is dependent upon the following libraries:

- Newtonsoft JSON.NET by James Newton-King (see https://www.newtonsoft.com/).
JSON.NET is licensed under the MIT license; see LICENSE.Newtonsoft.Json.txt
for details. A patched version of the library (Newtonsoft.Json.CH.dll) is
shipped with XenServer.NET. Its source code and license file can be found in
https://github.com/xenserver/dotnet-packages.
48 changes: 25 additions & 23 deletions ocaml/sdk-gen/csharp/README.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
XenServer.NET
=============

XenServer.NET is a complete SDK for Citrix Hypervisor, exposing the Citrix
Hypervisor API as .NET classes. It is written in C#.
XenServer.NET is a complete SDK for XenServer, exposing the XenServer
API as .NET classes. It is written in C#.

XenServer.NET includes a class for every API class, and a method for each API
call, so API documentation and examples written for other languages will apply
Expand All @@ -20,18 +20,18 @@ under the BSD 2-Clause license.
Reference
---------

For Citrix Hypervisor documentation see https://docs.citrix.com/en-us/citrix-hypervisor/
For XenServer documentation see https://docs.citrix.com/en-us/citrix-hypervisor/

The Citrix Hypervisor Management API Reference is available at
The XenServer Management API Reference is available at
https://developer-docs.citrix.com/projects/citrix-hypervisor-management-api/en/latest/

The Citrix Hypervisor Software Development Kit Guide is available at
The XenServer Software Development Kit Guide is available at
https://developer-docs.citrix.com/projects/citrix-hypervisor-sdk/en/latest/

For community content, blogs, and downloads, visit
https://www.citrix.com/community/citrix-developer/

To network with other developers using Citrix Hypervisor visit
To network with other developers using XenServer visit
https://discussions.citrix.com/forum/101-hypervisor-formerly-xenserver/


Expand All @@ -49,14 +49,15 @@ XenServer.NET is dependent upon the following libraries:
- Newtonsoft JSON.NET by James Newton-King (see https://www.newtonsoft.com/).
JSON.NET is licensed under the MIT license; see LICENSE.Newtonsoft.Json.txt
for details. A patched version of the library (Newtonsoft.Json.CH.dll) is
shipped with XenServer.NET.
shipped with XenServer.NET. Its source code and license file can be found in
https://github.com/xenserver/dotnet-packages.


Downloads
---------

This archive contains the following folders that are relevant to .NET developers:
- XenServer.NET\bin: contains the ready compiled binaries
- XenServer.NET: contains the ready compiled binaries in the form of a NuGet package.
- XenServer.NET\src: contains the source code shipped as a Visual Studio project.
- XenServer.NET\samples: contains the examples shipped as a Visual studio solution.

Expand All @@ -66,24 +67,25 @@ Getting Started

Extract the contents of this archive.

A. To use the compiled binaries in your code:
1. Copy XenServer.dll and Newtonsoft.Json.CH.dll
from the bin folder into your own workspace.
2. In Visual Studio, add references to all DLLs from your own program.
Project > Add Reference > Browse.
3. You should now be ready to compile against XenServer.NET.
A. To build the source code:
1. Open the project XenServer.csproj in Visual Studio.
2. You should now be ready to build the source code.

B. To build the source code:
1. Copy Newtonsoft.Json.CH.dll from the bin
folder into the source code folder at the same level as the project file
XenServer.csproj
2. Open the project XenServer.csproj in Visual Studio.
3. You should now be ready to build the source code.
B. To use the NuGet package in your code (offline):
1. Add the location of the package as a NuGet source:

```pwsh
nuget sources Add -Name "Offline Package" -Source "/full/path/to/package/directory"
```

2. Install the package

```pwsh
nuget install XenServer.NET
```

C. To run the examples:
1. Copy XenServer.dll and Newtonsoft.Json.CH.dll
from the bin folder into the samples folder at the same level as the
project file XenSdkSample.csproj.
1. Follow steps B.1 and B.2
2. Open XenSdkSample.sln inside Visual Studio (2019 or greater).
3. You should now be ready to compile the solution and run the examples.
The solution project is a console application expecting the parameters
Expand Down
9 changes: 9 additions & 0 deletions ocaml/sdk-gen/csharp/autogen/dune
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@
(action (copy %{deps} %{targets}))
)

(rule
(targets README-NuGet.md)
(deps
../README-NuGet.dist
)
(action (copy %{deps} %{targets}))
)

(alias
(name generate)
(deps
LICENSE.txt
README.txt
README-NuGet.md
(source_tree .)
)
)
Expand Down
71 changes: 3 additions & 68 deletions ocaml/sdk-gen/csharp/autogen/samples/XenSdkSample.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{869DC514-BCC0-42D7-BFA7-077005B23107}</ProjectGuid>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>XenSdkSample</RootNamespace>
<AssemblyName>XenSdkSample</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
Expand All @@ -32,65 +17,15 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<Reference Include="Newtonsoft.Json.CH">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Newtonsoft.Json.CH.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="XenServer">
<HintPath>.\XenServer.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="GetVariousRecords.cs" />
<Compile Include="Logger.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestBase.cs" />
<Compile Include="VmPowerStates.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
68 changes: 0 additions & 68 deletions ocaml/sdk-gen/csharp/autogen/src/Properties/AssemblyInfo.cs

This file was deleted.

Binary file added ocaml/sdk-gen/csharp/autogen/src/packageIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 32 additions & 4 deletions ocaml/sdk-gen/csharp/templates/XenServer.csproj.mustache
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>0.0.0</Version>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<OutputType>Library</OutputType>
<RootNamespace>XenAPI</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>XenServer.NET</Title>
<Authors>Citrix Systems, Inc.</Authors>
<PackageId>$(AssemblyName).NET</PackageId>
<Product>$(AssemblyName).NET</Product>
<Description>.NET wrapper for the XenServer API</Description>
<Copyright>Copyright (c) Citrix Systems, Inc. All rights reserved.</Copyright>
<PackageTags>citrix hypervisor virtualization sdk jsonrpc .net c# xen xenserver</PackageTags>
<PackageLicenseExpression>BSD-2-Clause</PackageLicenseExpression>
<RepositoryUrl>https://github.com/xapi-project/xen-api</RepositoryUrl>
<PackageIcon>packageIcon.png</PackageIcon>
<RepositoryType>git</RepositoryType>
<PackageReadmeFile>README-NuGet.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<None Include=".\lib\netstandard2.0\Newtonsoft.Json.CH.dll" Pack="true" PackagePath="lib\netstandard2.0\Newtonsoft.Json.CH.dll" />
<None Include=".\lib\net45\Newtonsoft.Json.CH.dll" Pack="true" PackagePath="lib\net45\Newtonsoft.Json.CH.dll" />
<None Include=".\LICENSE.Newtonsoft.Json.txt" Pack="true" PackagePath="LICENSE.Newtonsoft.Json.txt" />
<None Include=".\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt" />
<None Include=".\packageIcon.png" Pack="true" PackagePath="\" />
<None Include=".\README-NuGet.md" Pack="true" PackagePath="\" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="Newtonsoft.Json.CH.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\lib\netstandard2.0\Newtonsoft.Json.CH.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="Newtonsoft.Json.CH.dll">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Newtonsoft.Json.CH.dll</HintPath>
<HintPath>.\lib\net45\Newtonsoft.Json.CH.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit 4adbf80

Please sign in to comment.