2

It is possible to implement in .csproj to during building get Version from reference .dll and set the same version for this project.

<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>
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Silny ToJa
  • 1,815
  • 1
  • 6
  • 20

1 Answers1

0

How about creating a Directory.Build.props file that contains the version? 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

Gabriel
  • 226
  • 2
  • 6
  • This is a bit more complex because I share some interface to another team in the form of a .dll and then it loads the .dll generated by them. And such a solution will not be very practical for my needs. – Silny ToJa Feb 28 '22 at 13:23
  • Maybe this is what you are looking for? https://stackoverflow.com/a/49627234/18307736 – Gabriel Feb 28 '22 at 13:50