<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Version>1.0.0</Version>
<FileVersion>1.0.0</FileVersion>
</PropertyGroup>
</Project>
你也可以引用外部*.props
文件:
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="../Version.props"/>
</Project>
Version.props文件内容:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageVersion>2.0.0-preview4</PackageVersion>
<PackageReleaseNotes></PackageReleaseNotes>
<AssemblyVersion>$(Version)</AssemblyVersion>
<FileVersion>2.0.0</FileVersion>
<Version>2.0.1</Version>
</PropertyGroup>
</Project>
Console.WriteLine({namespace}.Generated.Version.FileVersion);
Console.WriteLine({namespace}.Generated.Version.Current);
Console.WriteLine({namespace}.Generated.Version.AssemblyVersion);
- 如果项目文件中没有设置版本号,则会自动创建一个版本号为1.0.0