Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget package - rename a file to be based on project namespace

As part of my package I need to add an xml file in a settings folder and name it {myrootnamespace}Settings.xml.

It this possible? I've been looking at the install.pss1 to achieve this but my powershell isn't up to much.

like image 414
keeney Avatar asked Dec 22 '11 16:12

keeney


1 Answers

I've cracked it. I'm creating a file called settings.xml in the settings folder and renaming it accordingly.

param($installPath, $toolsPath, $package, $project)


    $rootnamespace = $project.Properties.Item("RootNamespace").Value

     $path = [System.IO.Path]
    $settings = $path::Combine($path::GetDirectoryName($project.FileName), "Settings\settings.xml")


    $settingsfile = $project.ProjectItems.Item("Settings").ProjectItems.Item("settings.xml")

    $settingsfile.Name = ($rootnamespace + 'Settings.xml')
like image 116
keeney Avatar answered Oct 03 '22 10:10

keeney