There are so many blogs available to creating nuget package but i would like to go in more details with powershell script option in that.
Use GUI tool
Using commnad lines (http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package ) you can create whole package however better way is to use GUI (Nuget Package Explorer)
Please look below link & follow step
Know about Directory structure  
Directory structure of Nuget Package as per docs.nuget.org
- tools – contains Powershell scripts
 - lib – contains assemblies (dlls)
 - content – contains files to be added on root path
 
Alter web.config or app.config and Source
If you want to add some settings in configuration file then it is also possible using .tranform
Just add web.config or app.config in \content folder with .tranform extension e.g.
web.config.transform
app.config.tranform
Using Powershell  Script
Now if you want some manipulation with files in project then you have to add Powershell Script  
under \tool folder , following 3 types files you can add for that , read about in more details at here
- Init.ps1 runs the first time a package is installed in a solution.
 - Install.ps1 runs when a package is installed in a project.
 - Uninstall.ps1 runs every time a package is uninstalled.
 
Example to change property value of  Project's Item & dispaly popup Message
Here i am going to create install.ps1 and add powsershell script to change property of Test.exe file  
Copy To Output Directory = Copy Always
using  
$project.ProjectItems.Item("Test.exe").Properties.Item("CopyToOutputDirectory").Value = 1  
also add script to open popup at last as per shown in below figs.
Refer this http://jameschambers.com/blog/powershell-script-examples-for-nuget-packages for more scripts
Refer this http://powershell.com/cs/blogs/ebook/archive/2009/03/30/chapter-13-text-and-regular-expressions.aspx for more string operation and formatting by powershell

 
No comments:
Post a Comment