[英]Using NuGet.exe to install/update content-only package without a project file
We have a local NuGet feed that includes some JS content-only packages. 我们有一个本地NuGet提要,其中包含一些仅限JS内容的包。
I want to install those packages in a plain JS app (that I edit in Brackets and where I don't use VS at all). 我想在一个普通的JS应用程序中安装这些软件包(我在Brackets中编辑,我根本不使用VS)。 Obviously something like Bower would be more appropriate, but I don't want to maintain two package feed systems.
显然像Bower这样的东西会更合适,但我不想维护两个包裹饲料系统。
If I do nuget install MyPackage
, it downloads and unpacks the packages, but does not copy content files to subfolders (in fact it downloads the packages in the current folder). 如果我确实
nuget install MyPackage
,它会下载并解压缩包,但不会将内容文件复制到子文件夹(实际上它会下载当前文件夹中的包)。
Can I use nuget.exe to actually copy the content, or does it have to be an external step? 我可以使用nuget.exe实际复制内容,还是必须是外部步骤?
OK, here is some initial work I did for command-line update (which would work for install just as well, if you modify packages.config manually). 好的,这是我为命令行更新做的一些初步工作(如果你手动修改packages.config,它也适用于安装)。
It has the following limitations: 它有以下限制:
Code: 码:
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'
$packagesDirectory = (Get-Item nuget_packages)
$packagesDirectory.GetDirectories() | % {
Write-Host "Deleting $_"
Remove-Item $_.FullName -Recurse
}
Write-Host "Starting nuget.exe"
Start-Process nuget -ArgumentList "install packages.config" -WorkingDirectory nuget_packages -NoNewWindow -Wait
$packagesDirectory.GetDirectories() | % {
$contentPath = Join-Path (Join-Path $packagesDirectory.Name $_) 'content'
if (!(Test-Path $contentPath)) {
return;
}
Get-ChildItem $contentPath -Exclude *.transform | % {
$target = $_.Name
if (Test-Path $target) {
Write-Host "Deleting $target"
Remove-Item $target -Recurse
}
Write-Host "Copying $(Join-Path $contentPath $_.Name) to $target"
Copy-Item $_.FullName -Destination $target -Recurse
}
}
I used the tag <contentFiles>
with flatten="true" to download package files at the root. 我使用标签
<contentFiles>
with flatten =“true”在根目录下载包文件。 My nuget package contains Typescript files. 我的nuget包中包含Typescript文件。
<contentFiles>
<files include="cm-common/**/*" buildAction="None" flatten="true" />
</contentFiles>
I was initially using the <files>
tag, this extracts the files at the location root/package.name/content/{files} 我最初使用的是
<files>
标签,这会在位置root / package.name / content / {files}中提取文件
This might help someone 这可能对某人有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.