ShP
ShP

Reputation: 1143

Update AssemblyInfo.cs with Nuget package

Is it possible to update AssemblyInfo.cs file with nuget?

The only solution that crossing my mind at the moment is to use Install.ps1 and to play around with content there, but that can be messy. Is there any more elegant solution?

Upvotes: 0

Views: 768

Answers (2)

vendettamit
vendettamit

Reputation: 14677

There's no other way till now to update/add an entry in the a class with in project. To perform custom operation the Install.ps1 and Uninstall.ps1 files were introduced. The powershell script is passed with objects of EnvDTE to perform the operations with the files of a project/solutions.

You can take a look at this sample reference. Though the sample author is trying to insert the XMLConfigurator in either Main or Application_Start() method. you can customize the following part to edit the AssemblyInfo.cs instead of Program.cs

param($installPath, $toolsPath, $package, $project)
// ==> Change
$item = $project.ProjectItems.Item("AssemblyInfo.cs")

Upvotes: 1

Emond
Emond

Reputation: 50672

During the installation of a nuget package you cannot modify existing files unless you use the powershell script. Messing with existing content of files might easily break whatever is in the file. (Personal note: I would be extremely annoyed)

You can add files but you should be careful with that because those files might get replaced when the developer upgrades the package.

Some packages have a readme.txt in their root with instructions, that might be a way to give instructions to the developer as it will open after installing the package.

Providing good documentation and refraining from messing with other files or adding a lot of files to a solution might be the friendliest way.

Upvotes: 1

Related Questions