2018年6月3日 星期日

[Visual Studio] Same assembly information for all project in a solution


 Visual Studio   Assembly Information   



Introduction


Our goal is not to edit every project’s assembly information one by one in a visual studio’s solution.
The way is using the same one and make others have reference on it by using link file.



Environment


Visual Studio 2017 community


Implement


Create global Assembly information file

Create a solution folder, like “Assembly” for example, and find AssemblyInfo.cs file in any project.
Copy it and paste it to the Assembly folder. We will call it as “Global assembly file” in the later article to distinguish from the projects’ ones.






Update it

I suggest to update the Title and Product name in the global assembly file.

[assembly: AssemblyTitle("Wahlee.Infra")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wahlee.Infra")]
[assembly: AssemblyCopyright("Copyright ©  2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]



Reference it

Here are two ways to make a project reference the global assembly file.

1.  Remove the exist AssemblyFile.cs, then add an exist item – the global assembly file, by “Add As Link”.



Or use the bellow manual way.


2.  Open project’s .csproj file, paste the following settings inside it.

<ItemGroup>
    <Compile Include="..\Assembly\AssemblyInfo.cs">
      <Link>Properties\AssemblyInfo.cs</Link>
    </Compile>
</ItemGroup>

Don’t forget to update the path for your own custom path.





Reference






沒有留言:

張貼留言