.net核心项目中的SharedAssemblyInfo是否等效? [英] SharedAssemblyInfo equivalent in .net core projects?

查看:62
本文介绍了.net核心项目中的SharedAssemblyInfo是否等效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我希望解决方案中的多个项目共享相同的程序集信息(主要是AssemblyVersion)时,我通常使用此处说明的技术:> https://blogs.msdn.microsoft.com/jjameson/2009/04/03/shared-assembly -info-in-visual-studio-projects /

When I wanted multiple projects in a solution to share the same assembly informations (mainly AssemblyVersion), I used to use the tecnique explained here: https://blogs.msdn.microsoft.com/jjameson/2009/04/03/shared-assembly-info-in-visual-studio-projects/

现在我们正在研究.net核心和asp.net核心项目的解决方案,希望所有项目共享相同的AssemblyVersion,但是现在每个项目的版本都存储在.csproj文件中(我们使用的是vs2017)

Now we're working on a solution of .net core and asp.net core projects and we want all projects to share the same AssemblyVersion, but now each project's version is stored inside it's .csproj file (we're using vs2017)

我尝试用< GenerateAssemblyProductAttribute> true< / GenerateAssemblyProductAttribute> ,但是新文件是在构建时创建的。

I tried with generating info with <GenerateAssemblyProductAttribute>true</GenerateAssemblyProductAttribute> but the new file is created at build-time

有没有办法像旧的 SharedAssemblyInfo.cs方式那样集中这些信息?

Is there a way to centralize this information like in the "old" SharedAssemblyInfo.cs way?

推荐答案

您可以添加导演ry.Build.props 文件位于要为其默认属性的所有.csproj文件之上。此 .props 文件将自动导入到其下面所有 .csproj 文件中。您可以在其中设置常用属性:

You can add a Directory.Build.props file above all the .csproj files that you want to default properties for. This .props file will automatically be imported in all the .csproj files below it. You can set common properties in it:

<Project>
  <PropertyGroup>
    <Company>Erhardt Enterprises</Company>
    <Copyright>Erhardt Enterprises ©</Copyright>
  </PropertyGroup>
</Project>

这些MSBuild属性将应用于所有 .csproj 文件。因此,当生成程序集属性时,这些值将在所有项目中使用。

And these MSBuild properties will apply to all the .csproj files under it. So when the assembly attributes are generated, these values will be used across all projects.

这是将所有MSBuild属性映射到程序集属性

这篇关于.net核心项目中的SharedAssemblyInfo是否等效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆