I had problems with VS Online and nuget-restore. It would report that it couldn't find packages, which Visual Studio 2015 found and installed. So I specified in nuget's targets file to use APIv3 and APIv2. Since than, all nuget packages are always found, but I'm starting to experience different, rather random, errors with npm.
I've a pre-build script (configured in my project file) which installs all necessary npm and bower packages, and afterwards runs gulp. This works fine locally, and most of the times also online. But every ~4th time on average, I get an exception similar to this:
EPERM, open 'C:\NPM\Cache\fedb6d47-PM-Cache-clone-1-0-2-package-tgz.lock'
or this:
EPERM, open 'C:\NPM\Cache\ca5822dc-sh-isarguments-3-0-4-package-tgz.lock'
I was working on the gulpfile in the beginning, so I thought some of those changes caused it, but now, I'm not even touching that project anymore, and it compiled fine until suddenly I got this error again.
In the meanwhile, I've added a tiny change to commit and push it, and it compiles fine again. Any idea what can cause this and how I can at least reduce the risk of getting that error?
Here is my pre-build powershell script:
param($build_config)
$webProjectName = "WEB_PROJECT"
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
cd $dir
cd ..\src\$webProjectName
echo "npm install"
npm install
echo "bower install"
bower install
echo "gulp $build_config"
gulp $build_config
Update:
I used to execute that powershell script via
PowerShell -File script.ps1
and after switching to
PowerShell -NonInteractive -NoProfile -Command script.ps1
it seemed to have fixed the error, however after ~20 successful builds, I got again a similar problem (although much less often now)
Further investigation shows, there might be some problem with the network connection or a proxy, which is weird, because bower install always succeeds. Anyhow, the solution which is working quite well for me is the following:
use the native npm install build step from visual studio online as a first step
add an environment variable to the build service in order to identify in your script, that it's running on the build server (I called it VSO and assigned it the value 1)
check in your script if it's running on the build server or not, in powershell you can do it like this:
If ($env:VSO -ne 1)
{
echo "npm install"
npm install
}
Related
Hoping someone can assist me.
I am currently working on creating a project template for myself to use going forward for Electron/React.
Have most of it working except for my preinstall script.
File Hierarchy:
-/root
--/package.json
--/react
---/package.json
--/electron
---/package.json
Description: Have created a Powershell script Set-Path into each of these directories and run npm install for each of the 3 packages.
Issue: Script gets stuck in a loop installing over and over.
Code Example:
$root = Get-Location
$locations = $root,"$root/electron","$root/react"
Foreach ($location in $locations) {
Set-Location $locations
npm install
}
Set-Location $root
Does anyone know how to prevent this? Either by making Powershell wait for NPM install to run in each loop or by a better way to run npm install on 3 packages at once.
Found the issue and want to post it incase anyone finds themselves in a similar bind.
Essentially the issue was with the NPM Package and how I set it up.
I had named the NPM script that calls this PS Script "Preinstall", and since this PS Script also would perform an NPM install for the package, this would result in an infinite loop.
Solutions:
Remove initial NPM install from PS Script and let NPM Install via the CLI call the preinstall script as intended.
Rename NPM Script to something else, however this would not be the solution that results in the most ease of use.
E.g. of NPM Script
"preinstall": "#powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./preinstall.ps1"
I'd like to have my TFS 2103 build update some of the NuGet packages in the project to their latest versions before the build.
I've written a pre-build script to do this by invoking the nugget.exe update command:
& .\.nuget\nuget update ".\XXX.Main.Web\XXX.Main.Web.csproj" -Source Initial -Safe -Id XXX.Feature.Test -Verbosity detailed
The log file contains:
Looking for installed packages in 'packages'. Updating
'XXX.Main.Web'... NuGet.CommandLineException: Unable to find
'XXX.Feature.Test'. Make sure they are specified in packages.config.
I've tried running the command manually on the build server from the command prompt and it works as I would expect. I've also checked that script is being run from the correct folder.
The package certainly exists in Packages.config.
Has anyone managed to get nugget.exe update working successfully within a TFS powershell script?
After much head scratching I've found that the pre-build script is run pre fetching the packages from NuGet. Running the powershell script manually after the build had completed was fine as the packages has subsequently downloaded.
The NuGet message is somewhat misleading.
My solution is to run a NuGet.exe restore command prior to runing the update command and everything now works.
I'm having serious problems getting the last pieces of my TeamCity configuration in place.
I have a powershell step that executes the following commands:
& npm install
& grunt build
logging the following output:
Build (Powershell) (1s)
[13:18:08]PowerShell Executable: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
[13:18:08]Working directory: C:\BuildAgent\work\6a434ee5d01fd0d9
[13:18:08]PowerShell arguments: [-NonInteractive, -ExecutionPolicy, ByPass, -File, C:\BuildAgent\temp\buildTmp\powershell8407335260182621582.ps1]
[13:18:09]Error: ENOENT, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'
[13:18:09]
[13:18:09]grunt-cli: The grunt command line interface. (v0.1.13)
[13:18:09]Process exited with code 0
I've seen that this is a known problem, but none of the solutions has worked for me so far.
My setup is the following: I have two virtual machines in Azure, build and agent. Both are connected to the same AD domain, domain, in which there is a user domain\teamcityuser, who is of "standard" class (i.e. not admin). This user runs both the build server (on the build instance) and the build agent (on the agent instance).
I've tried these things without success:
Creating the directory in the error message, making sure that domain\teamcityuser has full controll access rights to it.
Creating an npm directory under C:\Users\teamcityuser\AppData\Roaming
Creating a file C:\Windows\System32\config\SystemProfile\.npmrc with the contents prefix=C:\npm-global, as well as creating the latter folder
Running npm cache clean before running the build
Installing a global npm package through npm install -g npm
What more can I try to get this working?
And to avoid the XY problem, here's my actual problem:
I have a .NET Web API project with CI setup through this TeamCity installation, via Octopus Deploy and to the hosting server. I also have a github repo with the code for a web SPA that will consume the API. The spa is built with grunt build, after which there's a dist folder with everything I need to deploy.
I'd like to re-use as much as possible of the CI architecture to roll out the client too.
Given that path to executable contains SysWOW64, this is an x32 Powershell, therefore, it refers to x32 system profile path, which is located at C:\Windows\sysWOW64\config\systemprofile. So, you need to use that path as your base in order to implement any workarounds, say, create C:\Windows\sysWOW64\config\systemprofile\AppData\Roaming\npm folder, and not plain C:\Windows\system32\config\systemprofile\AppData\Roaming\npm.
I installed paket from nuget in Nuget Package Manager Console with:
Install-Package paket
I then tried to run paket convert-from-nuget. It stalled out on a user prompt (it wouldn't let me type into the package manager console). My next thought was to run it from command line, but how to do so is not documented.
Just putting paket convert-from-nuget into a standard dev command prompt results in an error saying "paket" is not recognized.
How do I run paket from the command line or powershell, and how do you specify which solution to work against?
The way to setup paket in your repository is as follow:
1 Download a release of paket.bootstrapper.exe
This is a lightweight utility which obtains and updates paket.exe, pick stable release from official release page:
https://github.com/fsprojects/Paket/releases
2 create a .paket folder
md .paket
3 put the downloaded bootstrapper in this folder and invoke it
cd .paket
paket.bootstrapper
now you have an up-to-date paket.exe ready to ease your handling of dependencies.
4 convert from nuget
cd ..
.paket\paket convert-from-nuget
Please checkout the https://github.com/fsprojects/Paket.VisualStudio also for Visual Studio plugin to help you authoring paket.dependencies and paket.references file
Please also join https://gitter.im/fsprojects/Paket if you have any questions.
The Chocolatey package modifies the PSModulePath envivornment variable. I've observed that sometimes that modification isn't picked up until the system is restarted (or at least not until the user logs out and back in again). In the meantime, you can import the module using:
Import-Module <path-to-packages>\Paket.PowerShell\Paket.PowerShell.psd1
The packages path is usually something like C:\Chocolatey\lib. OTOH, re-reading your question, are you referring to the Nuget inside of Visual Studio? If so, that downloads from NuGet.org and that pkg puts paket.exe in $(SolutionDir)\packages\Pakget.1.18.5\tools\paket.exe. Your version number may varying.
Unfortunately the fact that PowerShell V5 introduces Install-Package (which downloads from Chocolatey by default) is going to get a little confusing vis-a-vie the NuGet Package Manager Console's Install-Package in Visual Studio.
I'm trying to setup a large number of build agents and so far i can install all the dependencies silently (using powershell, nuget and chocolatey).
However i cannot install the tool IlMerge without the damn GUI popping up.
Ive tried all the usual msiexec switches and they are just ignored. does anyone know of a way of getting this tool on a box in an unattended way?
Or should i just repack the thing in zip/msi?
This is on windows server 2008 R2
If i run
Invoke-Expression "msiexec $installerPath\ilmerge.msi /passive"
I still get a security dialog.
Currently i'm just thinking ill do this:
Copy-Item x:\installs\ilmerge.exe "C:\Program Files (x86)\ILMerge"
seeing as its only one file.
Below worked for me, no security dialogs.
cp ILMerge.msi \\Server\admin$
winrs -r:Server ILMerge.msi /passive
dir "\\Server\C$\Program Files (x86)\Microsoft\ILMerge"
With chocolatey you would have just needed to specify -ia '/quiet' as the package was not silent by default. This was specified by the tag notSilent and it was also in the description (http://chocolatey.org/packages/ilmerge/2.11.1103.1).
The latest package is just the executable, so you can just install it. http://chocolatey.org/packages/ilmerge