In VS 2017, or more accurately, the old project format used in VS 2017, each project had a 'Properties' folder with an AssemblyInfo.cs
file which held things like project version, copyright, etc.
If you wanted to share some of that information between several projects, say all those in a particular solution, you created a AssemblyInfo_Shared.cs
file, moved the shared properties into it, removing them from the original AssemblyInfo.cs
file, then you would 'link' the shared version into each separate project.
Now when you build, information that is in AssemblyInfo_Shared.cs
will be shared between all projects where as project-specific values would remain in the original AssemblyInfo.cs
file.
However, in the new project format, these values are all embedded into the project's file, which now is a simple XML file. How can you share settings between projects now?
Properties (and even items) in the project file are processed by MSBuild, and can easily be refactored into .props
and .targets
files that are shared among your projects.
With the new project file format, MSBuild will automatically import files named Directory.Build.props
at the beginning of your project, and Directory.Build.targets
at the end - this includes searching up the folder tree until one of these is found. With this, it is very easy to share properties across all projects in your solution: simply create a Directory.Build.props
file in the solution folder with your version properties, and every project will share those properties.