[英]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.