由于dotnet核心移回了 .csproj 格式,因此有一个新的自动生成的 MyProject.AssemblyInfo.cs
[assembly:AssemblyCompany( MyProject)] [assembly:AssemblyVersion( 1.0。 0.0)]请注意,这会在每个版本中自动重新生成。 以前,该文件是在/ obj /目录中找到的,但现在似乎只存在于内存中,因为在磁盘上找不到该文件,并且单击错误消息无法打开任何文件。
这是错误消息:
由于已定义在那里我无法在经典的 AssemblyInfo.cs 中定义它们。
在哪里/如何定义公司和项目的版本?
解决方案您已经注意到,可以在.csproj中控制大多数这些设置。
如果您希望将这些保留在AssemblyInfo.cs中,则可以关闭自动生成的程序集属性。
< PropertyGroup> < GenerateAssemblyInfo> false< / GenerateAssemblyInfo> < / PropertyGroup>如果您想了解引擎盖下发生的事情,请结帐 Microsoft.NET.GenerateAssemblyInfo.targets 在Microsoft.NET.Sdk中。
Since dotnet core moved back to the .csproj format there is a new autogenerated MyProject.AssemblyInfo.cs which contain among other.
[assembly: AssemblyCompany("MyProject")] [assembly: AssemblyVersion("1.0.0.0")]Note that this is automatically regenerated every build. Previously the file was found in the /obj/ directory, now it appears to be only in memory as the file can't be found on disk and clicking the error message does not open any file.
This is the error message:
Since they are defined there I can't define them myself in the classical AssemblyInfo.cs.
Where/how can I define the Company and Version of a project?
解决方案As you've already noticed, you can control most of these settings in .csproj.
If you'd rather keep these in AssemblyInfo.cs, you can turn off auto-generated assembly attributes.
<PropertyGroup> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup>If you want to see what's going on under the hood, checkout Microsoft.NET.GenerateAssemblyInfo.targets inside of Microsoft.NET.Sdk.
更多推荐
等效于dotnet core / csproj中的AssemblyInfo
发布评论