Powershell 使用init.ps1和nuget将文件复制到解决方案文件夹
我在nuget包的init.ps1中使用ps脚本时遇到问题。我试图在安装包时创建一个解决方案文件夹,然后将dll/PDB复制到此文件夹(并删除项目中包安装的源dll/PDB)。 我能够创建解决方案文件夹,但无法将文件从\content\temp目录复制到解决方案文件夹。 事实上,我确实希望文件系统上有一个真正的文件夹和一个解决方案文件夹相匹配,因此副本应该将文件复制到真正的文件系统文件夹,然后添加到解决方案文件夹中。Powershell 使用init.ps1和nuget将文件复制到解决方案文件夹,powershell,nuget,Powershell,Nuget,我在nuget包的init.ps1中使用ps脚本时遇到问题。我试图在安装包时创建一个解决方案文件夹,然后将dll/PDB复制到此文件夹(并删除项目中包安装的源dll/PDB)。 我能够创建解决方案文件夹,但无法将文件从\content\temp目录复制到解决方案文件夹。 事实上,我确实希望文件系统上有一个真正的文件夹和一个解决方案文件夹相匹配,因此副本应该将文件复制到真正的文件系统文件夹,然后添加到解决方案文件夹中。 复制部分不工作,我没有收到任何输出错误。有点迷路了 param($instal
复制部分不工作,我没有收到任何输出错误。有点迷路了
param($installPath, $toolsPath, $package, $project)
# Get the open solution.
$solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
# Create the parent solution folder.
$parentProject = $solution.AddSolutionFolder("MyDlls")
# Create a child solution folder.
$parentSolutionFolder = Get-Interface $parentProject.Object ([EnvDTE80.SolutionFolder])
$fileName = (Join-Path $installPath "\temp\mydll")
$projectFile = $parentSolutionFolder.AddFromFile($fileName)
Write-Host ""
Write-Host $sourcePath
Write-Host $parentSolutionFolder
我也遇到了同样的问题,并在BuildDeploySupport项目中找到了一个PowerShell脚本,它正好做到了这一点。您只需在多个位置更新要复制的文件夹的名称(下面链接的ps1中的Deploy\Support) 看 来自link(截至2017年11月30日):
出于兴趣,您要传递给$installPath的路径是什么$toolsPath@mitchimus这些路径由NuGet Powershell环境传递,并对应于安装包的绝对路径(“packages”目录中的一个目录,与解决方案文件位于同一目录中)和“tools”的路径$installPath中的文件夹。事实证明,该脚本不是递归的,但使其递归很容易。将第36行修改为:
ls-recurse$deployTarget | foreach object{
请复制相关部分(将链接保留为属性)。众所周知,网站会随着时间的推移而消失甚至改变。
param($installPath, $toolsPath, $package)
# find out where to put the files, we're going to create a deploy directory
# at the same level as the solution.
$rootDir = (Get-Item $installPath).parent.parent.fullname
$deployTarget = "$rootDir\Deploy\Support\"
# create our deploy support directory if it doesn't exist yet
$deploySource = join-path $installPath 'tools/deploy'
if (!(test-path $deployTarget)) {
mkdir $deployTarget
}
# copy everything in there
Copy-Item "$deploySource/*" $deployTarget -Recurse -Force
# get the active solution
$solution = Get-Interface $dte.Solution ([EnvDTE80.Solution2])
# create a deploy solution folder if it doesn't exist
$deployFolder = $solution.Projects | where-object { $_.ProjectName -eq "Deploy" } | select -first 1
if(!$deployFolder) {
$deployFolder = $solution.AddSolutionFolder("Deploy")
}
# add all our support deploy scripts to our Support solution folder
$folderItems = Get-Interface $deployFolder.ProjectItems ([EnvDTE.ProjectItems])
ls $deployTarget | foreach-object {
$folderItems.AddFromFile($_.FullName) > $null
} > $null