简体   繁体   English

从参考 dll 获取版本并为当前项目设置相同

[英]Get version from reference dll and set the same for current project

It is possible to implement in.csproj to during building get Version from reference.dll and set the same version for this project.可以在构建过程中实现 in.csproj 从 reference.dll 获取版本并为此项目设置相同的版本。

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <Version>After create .dll from this project it should return 1.0.2.0 from firstProject</Version>
</PropertyGroup>

<ItemGroup>
  <Reference Include="firstProject, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null">
    <HintPath>path\firstProject.dll</HintPath>
  </Reference>

How about creating a Directory.Build.props file that contains the version?如何创建包含版本的Directory.Build.props文件? This way all projects use the version from this file until a project defines its own version.这样,所有项目都使用此文件中的版本,直到项目定义了自己的版本。

For more information about the Direcotry.Build.props file, see: https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022有关 Direcotry.Build.props 文件的更多信息,请参阅: https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2022

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 同一解决方案中的项目到项目参考特定版本 - Project to Project reference specific Version in same solution 相同的 function 与相同的 arguments,来自相同的 dll 参考(相同的路径,相同的文件),适用于一个 .NET 项目,但不适用于另一个项目 - Same function with same arguments, from same dll reference (same path, same file), working for one .NET project, but not for an other 在.NET项目中部署时,为项目设置特定的参考版本 - Set specific reference version for project when deployed in .NET project (EasyHook) DLL 在同一项目中无法识别 - (EasyHook) DLL not recognized from within same project 使用从 C# DLL 获取 PS 脚本名称? 获取“对象引用未设置为 object 的实例。” - Using to get PS script name from a C# DLL? Getting "Object reference not set to an instance of an object." 使用类名获取用于我们项目的参考dll名称 - Get reference dll name used for our project with class name 在 .Net 5 项目中引用兼容的 .Net 框架 dll 但我得到一个例外 - Reference compatible .Net framework dll in .Net 5 project but I get an exception 设置.dll参考路径 - set .dll reference path 是否可以将同一装配的不同版本引用到单个项目中? - Is it possible to reference different version of the same assembly into a single project? 我可以从 .NET 6 项目中添加对 .NET 框架 DLL 的引用吗? - Can I add a reference to a .NET Framework DLL from a .NET 6 project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM