Using the CodePlex .NET API
CodePlex provides a set of .NET classes that expose the
web services functionality as a simple API.
API files can be downloaded from
here.
Please Note:
The CodePlex .NET API requires Microsoft Visual J# Version 2.0 Redistributable. This is normally installed with Microsoft Visual Studio or can be downloaded and installed from here.
ReleaseFile
Type | class |
Assembly | CodePlex.WebServices.Client.dll |
Namespace | CodePlex.WebServices.Client |
Constructors
Properties
public string Name { get; set; } Gets or sets the display name associated with the file. If not specified, the
FileName will be displayed.
public string MimeType { get; set; } Gets or sets the MIME type associated with the file. If not specified, the default value is
application/octet-stream.
public string FileName { get; set; } Gets or sets the file name associated with the file. If the value is a full path to the file, the path portion will be removed.
public byte[] FileData { get; set; } Gets or sets the byte data associated with the file.
public ReleaseFileType FileType { get; set; } Gets or sets the
ReleaseFileType associated with the file.
ReleaseService
Type | class |
Assembly | CodePlex.WebServices.Client.dll |
Namespace | CodePlex.WebServices.Client |
Constructors
public ReleaseService() Initializes a new instance of the
ReleaseService class.
Properties
public ICredentials Credentials { get; set; } Gets or sets the
ICredentials to be used while connecting to the web service.
Methods
public int CreateRelease(string projectName, string releaseName, string description, DateTime releaseDate, ReleaseStatus status, bool showToPublic, bool showOnHomePage, bool isDefaultRelease) Creates a new release in the specified project. The release name must be unique within the project.
Parameters Name | Type | Description |
projectName | string | The CodePlex project name. |
releaseName | string | The name of the release. |
description | string | The description field for the release. |
releaseDate | DateTime? | The date field for the release. Must be a valid date for releases with a status other than Planned. For Planned releases, this value is ignored. |
status | ReleaseStatus | The status field for the release. |
showToPublic | bool | true if the release is visible to the public, false if the release should only be visible to Coordinators and Developers. |
showOnHomePage | bool | true if the release is shown on the project home page, false otherwise. |
isDefaultRelease | bool | true to mark the release as the default release for the project, false otherwise. If there is an existing default release, that release will no longer be the default. |
ReturnsAn integer value specifying the ID of the newly created release.
public void UploadReleaseFiles(string projectName, string releaseName, IList<ReleaseFile> releaseFiles) Adds one or more files to an existing release. The release is identified by the name parameter.
Parameters Name | Type | Description |
projectName | string | The CodePlex project name. |
releaseName | string | The name for the release. |
releaseFiles | IList<ReleaseFile> | A list of ReleaseFile objects describing the files to add to the release. |
ReleaseFileType
Type | enum |
Assembly | CodePlex.WebServices.Client.dll |
Namespace | CodePlex.WebServices.Client |
Values RuntimeBinary | The file is a runtime binary (or may contain runtime binaries). |
SourceCode | The file contains source code associated with the release. |
Documentation | The file contains documentation associated with the release. |
Example | The file contains examples/sample code associated with the release. |
ReleaseStatus
Type | enum |
Assembly | CodePlex.WebServices.Client.dll |
Namespace | CodePlex.WebServices.Client |
Values Planned | The release is available, but has not been officially released. |
Released | The release has been officially released. Once a release is marked as Released it cannot be changed back to Planned. |
Examples
To create a Planned release:
ReleaseService releaseService = new ReleaseService();
releaseService.Credentials = new NetworkCredential("username", "password");
releaseService.CreateRelease("ProjectName", "New Release Name", "Description",
null, ReleaseStatus.Planned, true, false, false);
To create a Released release:
ReleaseService releaseService = new ReleaseService();
releaseService.Credentials = new NetworkCredential("username", "password");
releaseService.CreateRelease("ProjectName", "New Release Name", "Description",
DateTime.Now, ReleaseStatus.Released, true, false, true);
To upload files to a release:
ReleaseService releaseService = new ReleaseService();
releaseService.Credentials = new NetworkCredential("username", "password");
List<ReleaseFile> releaseFiles = new List<ReleaseFile>();
ReleaseFile releaseFile = new ReleaseFile();
releaseFile.Name = "File Display Name";
releaseFile.MimeType = "text/plain";
releaseFile.FileName = "readme.txt";
releaseFile.FileType = ReleaseFileType.Documentation;
// Read in the file data
releaseFile.FileData = File.ReadAllBytes(@"readme.txt");
releaseFiles.Add(releaseFile);
releaseService.UploadReleaseFiles("ProjectName", "New Release Name", releaseFiles);