JQuery NuGet NuGet Package Explorer ( ) install.ps1 common.ps1, , _references.js JQuery, API- JQuery IntelliSense.
, ( , ). JQuery , / ( , , ).
, OP.
common.ps1:
function AddOrUpdate-Reference($scriptsFolderProjectItem, $fileNamePattern, $newFileName) {
try {
$referencesFileProjectItem = $scriptsFolderProjectItem.ProjectItems.Item("_references.js")
}
catch {
return
}
if ($referencesFileProjectItem -eq $null) {
return
}
$referencesFilePath = $referencesFileProjectItem.FileNames(1)
$referencesTempFilePath = Join-Path $env:TEMP "_references.tmp.js"
if ((Select-String $referencesFilePath -pattern $fileNamePattern).Length -eq 0) {
"/// <reference path=""$newFileName"" />" | Add-Content $referencesTempFilePath -Encoding UTF8
Get-Content $referencesFilePath | Add-Content $referencesTempFilePath
}
else {
Get-Content $referencesFilePath | ForEach-Object { $_ -replace $fileNamePattern, $newFileName } > $referencesTempFilePath
}
Copy-Item $referencesTempFilePath $referencesFilePath -Force
Remove-Item $referencesTempFilePath -Force
}