0

I'm working on a nuget package that depends on the Unity and Unity.Mvc4 packages. My nuspec file has them listed as dependencies. Everything works, but when my package is installed the dependencies are installed first.

The Unity dependencies deploy files to the root of the project that my package has moved to a different location and customized, as such I don't want those files to exist in the root after my package is installed.

Is there any way to override dependency files in nuspec, or run a powershell script after install to clean them up?

Ryan Mann
  • 5,178
  • 32
  • 42

2 Answers2

1

You might add a Powershell script that move those files created by Unity to your actual project root.

For information about executing Powershell scripts during Nuget package installation, see the Nuget documentation. Note that these scripts must be placed within the tools folder of your Nuget package to be automatically executed.

andreask
  • 4,248
  • 1
  • 20
  • 25
0

Here's the code in my install.ps1 that did the trick if anyone wants it for reference.

# Runs every time a package is installed in a project

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

# $installPath is the path to the folder where the package is installed.
# $toolsPath is the path to the tools directory in the folder where the     package is installed.
# $package is a reference to the package object.
# $project is a reference to the project the package was installed to.

#EnvDTE Project Reference
#https://msdn.microsoft.com/en-us/library/envdte.project.projectitems.aspx

function deleteProjectItem($fileName) {
    $file = $null
    foreach ($item in $project.ProjectItems) {
        if ($item.Name.Equals($fileName, "InvariantCultureIgnoreCase")) {
            $file = $item
            break
        }
    }
    if ($file -ne $null) {
        Write-Host "Deleting: $($item.Name) ..." -NoNewline
        $item.Delete()
        Write-Host "Deleted!"
    }
}

deleteProjectItem "BootStrapper.cs"
deleteProjectItem "job_scheduling_data_2_0.xsd"
deleteProjectItem "Unity.Mvc4.README.txt"
Ryan Mann
  • 5,178
  • 32
  • 42