Appveyor: Package content hash validation failed, The package is different than the last restore - appveyor

I would like to configure CI in Appveyor for a .net project and I am struggling with following errors:
error NU1403: Package content hash validation failed for System.Collections.NonGeneric.4.3.0. The package is different than the last restore.
Every project restore happens to throw similar thing
There was similar question and one advice was to clear nuget cache.
Whats the best course of action here?
Thanks
Directory.Build.props
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
</PropertyGroup>
Build started
git config --global core.autocrlf true
git clone -q --branch=master https://github.com/User/App.git C:\projects\App
git checkout -qf 7066b969dd7564c573fb5e30fa6600a86c48644f
choco install opencover.portable
Chocolatey v0.11.3
Installing the following packages:
opencover.portable
By installing, you accept licenses for the packages.
Progress: Downloading opencover.portable 4.7.1221... 100%
opencover.portable v4.7.1221 [Approved]
opencover.portable package files install completed. Performing other installation steps.
Downloading opencover.portable
from 'https://github.com/OpenCover/opencover/releases/download/4.7.1221/opencover.4.7.1221.zip'
Progress: 100% - Completed download of C:\Users\appveyor\AppData\Local\Temp\1\chocolatey\opencover.portable\4.7.1221\opencover.4.7.1221.zip (7.76 MB).
Download of opencover.4.7.1221.zip (7.76 MB) completed.
Hashes match.
Extracting C:\Users\appveyor\AppData\Local\Temp\1\chocolatey\opencover.portable\4.7.1221\opencover.4.7.1221.zip to C:\ProgramData\chocolatey\lib\opencover.portable\tools...
C:\ProgramData\chocolatey\lib\opencover.portable\tools
ShimGen has successfully created a shim for OpenCover.Console.exe
ShimGen has successfully created a shim for OpenCover.Simple.Target.exe
ShimGen has successfully created a shim for OpenCover.Simple.Target.exe
The install of opencover.portable was successful.
Software installed to 'C:\ProgramData\chocolatey\lib\opencover.portable\tools'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Did you know the proceeds of Pro (and some proceeds from other
licensed editions) go into bettering the community infrastructure?
Your support ensures an active community, keeps Chocolatey tip-top,
plus it nets you some awesome features!
https://chocolatey.org/compare
choco install codecov
Chocolatey v0.11.3
Installing the following packages:
codecov
By installing, you accept licenses for the packages.
Progress: Downloading codecov 1.13.0... 100%
codecov v1.13.0 [Approved]
codecov package files install completed. Performing other installation steps.
Extracting 64-bit C:\ProgramData\chocolatey\lib\codecov\tools/codecov-win7-x64.zip to C:\ProgramData\chocolatey\lib\codecov\tools...
C:\ProgramData\chocolatey\lib\codecov\tools
ShimGen has successfully created a shim for codecov.exe
The install of codecov was successful.
Software installed to 'C:\ProgramData\chocolatey\lib\codecov\tools'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
dotnet --version
5.0.403
dotnet restore
Determining projects to restore...
C:\projects\App\Tests\Common.Tests\Common.Tests.csproj : error NU1403: Package content hash validation failed for System.Collections.NonGeneric.4.3.0. The package is different than the last restore. [C:\projects\App\App.sln]
appveyor.xml
version: '1.0.{build}'
image: Visual Studio 2019
branches:
only:
- master
init:
- cmd: git config --global core.autocrlf true
install:
before_build:
- choco install opencover.portable
- choco install codecov
- cmd: dotnet --version
- cmd: dotnet restore
build_script:
- cmd: dotnet build --configuration Release --no-restore
test_script:
- cmd: dotnet test --configuration Release --no-build --no-restore --verbosity minimal --test-adapter-path:. --logger:Appveyor /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:MergeWith="../TestResults/coverage.json" /p:CoverletOutputFormat=lcov
cache:
- '%USERPROFILE%\.nuget\packages -> **\project.json'
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml
deploy: off

At Feodor suggestion I added powershell script which removes package.lock.json files and it worked.
before_build:
- choco install opencover.portable
- choco install codecov
- ps: >-
Get-ChildItem .\ -include packages.lock.json -Recurse | foreach ($_) { remove-item $_.fullname -Force }
- cmd: dotnet --version
- cmd: dotnet restore

Related

My action runner for github is failing. How do I resolve yarn: command not found. Process completed with exit code 127?

I was running a self hosted github action runner but my jobs were failing with this error message in the picture. I searched stackoverflow before posting the question but couldn't find any relevant threads. Let me know if there are threads that I missed.
How do I resolve this error so that my github action runner can run my CI builds again?
The built-in GitHub Action runners have yarn installed on them by default but a self-hosted runner won't unless you install it. See relevant issue here: https://github.com/actions/setup-node/issues/182.
If you don't want to install yarn on your self-hosted runner you can install it in the workflows that need it. Just make sure to uninstall it afterward to keep your self-hosted runners clean.
# You'll need to make sure node is installed first
- name: Install Node
uses: actions/setup-node#v3
with:
node-version-file: '.node-version'
- name: Install yarn
run: npm install -g yarn
# Do what you need to do with yarn
# Uninstall when you're done
- name: Clean up
if: always()
run: npm uninstall -g yarn
I realised that the issue was literally as described in the error that for some reason yarn was not found on my computer. This was a little strange as I remembered installing yarn before.
Nevertheless I ran
brew install yarn
And ran brew update and upgrade just in case my homebrew was outdated
brew update
brew upgrade
And it resolved the error and issues.

Set up CI with Travis for .NET Core

I'm trying to set up a CI for my .NET Core 3.1 class library. I created an account at https://travis-ci.org/github and selected my repository containing the code for my class library for a CI build.
Travis is successfully watching my master branch for commits, but I cannot get the CI build to succeed.
My repository: https://github.com/MintPlayer/MintPlayer.AspNetCore.SitemapXml
Target framework: .NET Core 3.1
My latest .travis.yml file:
language: csharp
mono: none
dotnet: 3.1.302
script:
- dotnet restore
dist: trusty
sudo: required
History of attempted travis.yml files (all failed):
But somehow this always errors, this time with the following output:
Clean output:
docker stop/waiting
resolvconf stop/waiting
C# support for Travis-CI is community maintained.
Please open any issues at https://travis-ci.community/c/languages/37-category and cc #joshua-anderson #akoeplinger #nterry
Installing .NET Core
$ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$ export DOTNET_CLI_TELEMETRY_OPTOUT=1
E: Unable to locate package dotnet-sdk-3.1
E: Couldn't find any package by glob 'dotnet-sdk-3.1'
E: Couldn't find any package by regex 'dotnet-sdk-3.1'
The command "sudo apt-get install -qq dotnet-sdk-3.1=3.1.302*" failed and exited with 100 during .
Your build has been stopped.
Raw output: https://api.travis-ci.org/v3/job/709293291/log.txt
What's wrong with my travis.yml configuration. Why can't I CI test my class library with this config?
I mainly want to CI test for .NET Core. If mono could be included this would be very nice. All the examples you'd find in the git history are also examples that I digged up in other repositories.
You are using:
dist: trusty
That's Ubuntu 14.04.6 LTS which is not supported by .NET Core 3.1. Try a newer version of Ubuntu such as bionic.
This is also answered in the travis community post:
dotnet-sdk-3.0 is not available for Trusty (presumably because it’s EOL): https://packages.microsoft.com/ubuntu/14.04/prod/dists/trusty/main/binary-amd64/Packages Move to dist: xenial (which is the default so you can just omit it) or dist: bionic.

Run Cypress.io on Azure Pipelines Hosted Linux Agent

I'm trying to run Cypress tests on the Hosted Linux Pool for Azure Pipelines. Unfortunately, the Hosted Agent doesn't have all the dependencies for Cypress installed.
Running the documented apt-get doesn't work:
2018-05-18T21:03:14.7423331Z ##[section]Starting: Install cypress dependencies
2018-05-18T21:03:14.7474742Z ==============================================================================
2018-05-18T21:03:14.7488281Z Task : Bash
2018-05-18T21:03:14.7501148Z Description : This is an early preview. Run a Bash script on macOS, Linux, or Windows
2018-05-18T21:03:14.7513088Z Version : 3.127.0
2018-05-18T21:03:14.7524823Z Author : Microsoft Corporation
2018-05-18T21:03:14.7537179Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613738)
2018-05-18T21:03:14.7549730Z ==============================================================================
2018-05-18T21:03:15.0174503Z Generating script.
2018-05-18T21:03:15.0535056Z Script contents:
2018-05-18T21:03:15.0547355Z apt-get install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
2018-05-18T21:03:15.0656822Z [command]/bin/bash --noprofile --norc /opt/vsts/work/_temp/cac4d3f9-42e7-49f3-94f6-7d0444827d83.sh
2018-05-18T21:03:15.6040707Z Reading package lists...
2018-05-18T21:03:15.6085335Z Building dependency tree...
2018-05-18T21:03:15.6153815Z Reading state information...
2018-05-18T21:03:15.6186788Z Package libgconf-2-4 is not available, but is referred to by another package.
2018-05-18T21:03:15.6198707Z This may mean that the package is missing, has been obsoleted, or
2018-05-18T21:03:15.6211380Z is only available from another source
2018-05-18T21:03:15.6216969Z
2018-05-18T21:03:15.6229592Z E: Unable to locate package xvfb
2018-05-18T21:03:15.6242128Z E: Unable to locate package libnotify-dev
2018-05-18T21:03:15.6254440Z E: Package 'libgconf-2-4' has no installation candidate
2018-05-18T21:03:15.6268141Z E: Unable to locate package libxss1
2018-05-18T21:03:15.6370826Z ##[error]Bash exited with code '100'.
2018-05-18T21:03:15.7283047Z ##[section]Finishing: Install cypress dependencies
Running apt-get update takes forever (25 minutes and still not done).
Any clues on how to get Cypress working quickly on the Hosted Agent is welcome.
Note: I tried running on Windows, that works, fortunately, so I'm not completely blocked. But to use the Windows Agent I now have 2 agent phases which adds overhead due to artefact downloads and npm install overhead.
Solved the issue using a pre-pended Shell (Bash) task in VSTS agent phase prior to running Cypress:
apt-get -qq -y update
apt-get -qq -y install xvfb libgtk2.0-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2

TravisCI / Coverity: Warning - No files were emitted

I have a medium size github repository for which I configured Travis-CI/Coverity tools. About a month ago my setup had worked just fine: Travis compiled and built my application, and then performed the Coverity scan and I could see the results on my Coverity page.
However, lately, the Coverity analysis stopped working. I looked through the Travis log files and compared to the old logs when the builds were successful and that's what I found:
At the end of the log, the failed version contains the next warning:
[WARNING] No files were emitted. This may be due to a problem with your configuration or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at: /home/travis/build/name/repo-name/build/cov-int/build-log.txt
Extracting SCM data for 0 files...
...
So, the Travis builds are passing, but nothing is generated for the Coverity. I checked my Travis config file and it is identical to the commits when the Coverity builds were successful.
For the sake of experiment, I cloned my project repository, rolled back to the version when the builds were successful and set up Travis/Coverity for them. And guess what? Same warning! So, the identical setup that worked in the past (about 35 days ago), does not work anymore. Therefore, I make conclusion, something had changed on the part of Travis since it does not generate certain files.
I was wondering if anyone encountered this issue? and what it could be about? Are there some Travis settings I need to change?
Some additional info: I use CMake to build my project, and it has two dependencies: Qt and OpenSceneGraph (which I have to install for Travis).
This is the approximate script of my .travis.yml on my coverity_scan branch:
language: cpp
os: linux
compiler: gcc
sudo: required
dist: trusty
addons:
apt:
packages:
- cmake
- g++-4.8
coverity_scan:
project:
name: "name/project"
description: "Build submitted via Travis CI"
notification_email: email#domain.com
build_command: "make -j2 VERBOSE=1"
branch_pattern: coverity_scan
env:
global:
- PROJECT_SOURCE=${TRAVIS_BUILD_DIR}/src/
- PROJECT_BUILD=${TRAVIS_BUILD_DIR}/build/
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "...secure..."
before_install:
# download Qt
# ...
# download OpenSceneGraph
# ...
# imitate x server
- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
- sleep 3
install:
# install Qt
- sudo apt-get --yes install qt55base qt55imageformats qt55svg
# compiler
- export CXX="g++-4.8"
- export CC="gcc-4.8"
# install OpenSceneGraph
# ...
before_script:
# Qt location
# ...
# OpenSceneGraph variables
# ...
# create build folder
- mkdir $PROJECT_BUILD
- cd $PROJECT_BUILD
# cmake command
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/qt54/lib/cmake -DProject_BUILD_TEST=ON -DProject_VERSION=0.0.0 $PROJECT_SOURCE
script:
- if [[ "${COVERITY_SCAN_BRANCH}" == 1 ]];
then
echo "Don't build on coverty_scan branch.";
exit 0;
fi
# compile everything, if not coverity branch
- make -j2
# run unit tests
# ...
After some research and looking through existing examples, I finally made it work. To fix the warning, and, therefore, to make sure files are emitted for the analysis, it is necessary to explicitly specify the compiler binary (updated according to the comment) . In my .travis.yml I had to add a build_command_prepend before the build_command of the coverity_scan add-on. An example of the final look for that block is as below:
# ...
coverity_scan:
project:
name: "name/project"
description: "Build submitted via Travis CI"
notification_email: name#domain.com
# ! have to specify the binary (updated, thanks to Caleb)
build_command_prepend: "cov-configure --comptype gcc --compiler gcc-4.8 --template"
build_command: "make VERBOSE=1"
branch_pattern: coverity_scan
# ...

Unauthorized response from GitHub API on Appveyor

We just started with a new project and trying to get CI working via Appveyor.
It is an Aurelia web application so we need jspm on the build server.
On my workstation I configured jspm manually as suggested by #guybedford in his answer below and configured my authtoken in appveyor.yml script:
- jspm config registries.github.auth %JSPM_GITHUB_AUTH_TOKEN%
Currently my appveyor.yml looks like this, based on the Auto configuring section from JSPM
version: 1.0.{build}
os: Visual Studio 2015
build:
verbosity: detailed
environment:
JSPM_GITHUB_AUTH_TOKEN:#token from jspm registry export github (locally)#
install:
- ps: Set-Culture nl-NL
- ps: Install-Product node $env:nodejs_version
- cd src\Web
- npm uninstall jspm -g
- npm install -g jspm
- npm install -g gulp
- npm install
- jspm config registries.github.auth %JSPM_GITHUB_AUTH_TOKEN%
- jspm config registries.github.maxRepoSize 0
- jspm registry export github #output to see what the registry looks like
- jspm install -y
- gulp build
- cd ..\..
nuget:
account_feed: true
before_build:
- dnvm install -r clr -arch x86 1.0.0-rc1-update1
- dnu restore
- nuget restore
The jspm install - y command fails with the error: Unauthorized response for GitHub API.
How do I configure Github credentials properly with JSPM on AppVeyor?
It is best to take this token from jspm registry export github after configuring the credentials locally in order to use the exact same algorithm as jspm instead of doing a manual encoding.
If you really want manual encoding, the auth token actually takes the value of new Buffer(encodeURIComponent(username) + ':' + encodeURIComponent(password)).toString('base64').
After contact with the Appveyor team we figured oud that the node version was the problem.
Installing the stable version of Node works like a charm:
ps: Install-Product node stable