在使用.NET Core时是否需要AssemblyInfo? [英] Do I need AssemblyInfo while working with .NET Core?
问题描述
以前,Visual Studio自动创建了 AssemblyInfo.cs
文件,以包含程序集范围的属性,例如AssemblyVersion,AssemblyName等。
Previously, AssemblyInfo.cs
file was autocreated by Visual Studio to contain assembly-wide attributes, like AssemblyVersion, AssemblyName and so on.
在.NET Core和ASP.NET Core中, project.json
负责保存大部分信息。
In .NET Core and ASP.NET Core, project.json
is responsible for holding most of that information.
问题是:我是否需要再用该属性标记我的程序集?
如果不使用该属性标记程序集,该怎么办?
So the question is: do I need to mark my assemblies with that attributes anymore? What traps can I get in if I will not mark assembly with that attributes?
推荐答案
project.json 已替换 AssemblyInfo
。
AssemblyVersionAttribute
替换为版本
属性
version
Type: String
The Semver version of the project, also used for the NuGet package.
AssemblyNameAttribute
现在是名称
属性
name
Type: String
The name of the project, used for the assembly name as well as the name of the package. The top level folder name is used if this property is not specified.
等
更新:随着.NET Core工具MSBuild的发布, .csproj
取代了 project.json
。 AssemblyInfo.cs
文件又回来了,但是大多数设置已直接移至 .csproj
。有关更多详细信息,请参见相关的SO问题:等效于dotnet core / csproj中的AssemblyInfo :
Update: With the announcement of .NET Core Tools MSBuild, the .csproj
has replaced the project.json
. The AssemblyInfo.cs
file is back, but most of the settings have been moved directly to .csproj
. See related SO question for more details: Equivalent to AssemblyInfo in dotnet core/csproj :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<Version>1.2.3.4</Version>
<Authors>Author 1</Authors>
<Company>Company XYZ</Company>
<Product>Product 2</Product>
<PackageId>MyApp</PackageId>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
<Description>Description here</Description>
<Copyright>Copyright</Copyright>
<PackageLicenseUrl>License URL</PackageLicenseUrl>
<PackageProjectUrl>Project URL</PackageProjectUrl>
<PackageIconUrl>Icon URL</PackageIconUrl>
<RepositoryUrl>Repo URL</RepositoryUrl>
<RepositoryType>Repo type</RepositoryType>
<PackageTags>Tags</PackageTags>
<PackageReleaseNotes>Release</PackageReleaseNotes>
</PropertyGroup>
这篇关于在使用.NET Core时是否需要AssemblyInfo?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!