Internet Explorer is no longer supported. Many things will still work, but your experience will be degraded and some things won't function. Please use a modern browser such as Edge, Chrome, or Firefox.

Set Project Version

Sets the version elements in .NET project files to a specified value.

Script usage:

DotNet::Set-ProjectVersion(
	[FromDirectory: <text>],
	[Include: <@(text)>],
	[Version: <text>],
	[AssemblyVersion: <text>],
	[FileVersion: <text>],
	[PackageVersion: <text>]
);

Arguments:

NameFormatScript UsageUsage Notes
From directory
text
FromDirectory
Value note: "$WorkingDirectory".
Project files to set
@(text)
Include
See KB#1119 to learn more about masking syntax. Default value is "**.csproj".
Version
text
Version
Default value is "$ReleaseNumber".
Assembly version
text
AssemblyVersion
Value note: "don't set AssemblyVersion".
File version
text
FileVersion
Value note: "don't set FileVersion".
Package version
text
PackageVersion
Value note: "don't set PackageVersion".

Note: This operation is intended to be used when generating assembly info properties from a .NET project file. To set attributes in AssemblyInfo.cs, use DotNet::WriteAssemblyVersion.

Example:

# Build ~\src\MyProject.csproj with Release configuration, restoring NuGet packages from the InternalNuGet source
DotNet::SetProjectVersion
(
    Version: $ReleaseNumber,
    AssemblyVersion: $ReleaseNumber.0
    FileVersion: $ReleaseNumber.$BuildNumber
);