I am attempting to add Linux building and testing to a C# library I maintain. One library in the solution requires WinForms and so cannot be build on Linux. I added a ReleaseNoGui configuration to my solution, and I would like Linux to build that rather than Release. Is this possible? This is what I've tried, but it is still building Release.
(…)
image:
- Visual Studio 2019
- Ubuntu1804
configuration: Release
(…)
build:
project: MySolution.sln
parallel: true
verbosity: minimal
publish_nuget: true
publish_nuget_symbols: false
for:
-
matrix:
only:
- image: Visual Studio 2019
deploy:
- provider: NuGet
name: nuget_release
api_key:
(snipped...)
-
matrix:
only:
- image: Ubuntu1804
configuration: ReleaseNoGui
for.matrix specializes configs based on environment variables. Currently, image is unsupported environment variable.
To achieve what you want you can use the following appveyor.yml config instead:
environment:
matrix:
# Windows job
- job_name: Windows build
appveyor_build_worker_image: Visual Studio 2019
# Linux job
- job_name: Linux build
appveyor_build_worker_image: Ubuntu1804
matrix:
fast_finish: true
configuration: Release
build:
project: MySolution.sln
parallel: true
verbosity: minimal
publish_nuget: true
publish_nuget_symbols: false
for:
-
matrix:
only:
- job_name: Windows build
deploy:
- provider: NuGet
name: nuget
-
matrix:
only:
- job_name: Linux build
configuration: ReleaseNoGui
After reading Feodor's answer, I experimented with environment.matrix and added the configuration to the environment.matrix item, and came up with:
environment:
matrix:
# Windows job
- job_name: Windows build
appveyor_build_worker_image: Visual Studio 2019
configuration: Release
# Linux job
- job_name: Linux build
appveyor_build_worker_image: Ubuntu1804
configuration: ReleaseNoGui
matrix:
fast_finish: true
build:
project: MySolution.sln
parallel: true
verbosity: minimal
publish_nuget: true
publish_nuget_symbols: false
for:
-
matrix:
only:
- job_name: Windows build
deploy:
- provider: NuGet
name: nuget
which builds Linux with the correct configuration.
Related
I am installing JAVA with actions pipeline in github. To make faster the execution, I want to cache the java for next pipeline. The version I wanna use is 17 for JAVA. During first execution of pipeline, the specific version of java is installed correctly. When pipeline executed for 2nd time, the cached java is picked(Which I want too as well) but the it showing me the version 1.8 not 17. Can anyone help. Thanks
name: pipeline to install & cache java
on:
push:
branches:
- do/cs # or the name of your main branch
# manually run from the Actions tab
workflow_dispatch:
jobs:
build:
name: Install packeges
runs-on: windows-2019 # Win 10 IoT is not available on github actions
steps:
- name: Cache Java
id: cache-java
uses: actions/cache#v3
with:
path: 'c:\hostedtoolcache\windows\Java_Microsoft_jdk\17.0.3\x64'
key: ${{ runner.os }}-jdk-17.0.3
restore-keys: ${{ runner.os }}-jdk-17.0.3
- name: Install Java
if: ${{steps.cache-java.outputs.cache-hit != 'true'}} # condition to check if old installation is available in cache
uses: actions/setup-java#v3
with:
distribution: 'microsoft'
java-version: '17'
architecture: 'x64'
- name: Verify Java installation
run: |
echo "java version:"
java -version
I am interested in running build for my Swift project on CI with GitHub Actions
I use the following ci.yml:
Build:
runs-on: macOS-latest
steps:
- name: Install Swift
uses: slashmo/install-swift#v0.2.1
with:
version: 5.7
- name: Checkout
uses: actions/checkout#v1
- name: Build
uses: sersoft-gmbh/xcodebuild-action#v2
with:
project: <Project>.xcodeproj
scheme: <Scheme>
destination: "platform=iOS Simulator,name=iPhone 14 Pro Max"
action: build
I am facing a problem here:
xcodebuild: error: Could not resolve package dependencies:
package at '/Users/runner/work/path/to/my/package' is using Swift tools version 5.7.0 but the installed version is 5.5.0
I want to use swift-tools-version equal to 5.7.0, not the lower one
Please, help me install the version I need
Looks like I made it work. I added this step in my workflow:
- name: Select Xcode
run: sudo xcode-select -s "/Applications/Xcode_14.0.1.app"
and then specified the simulator environment:
env:
destination: 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.0'
I have a Sample Solution with a simple .NET Framework 4.8 Library Project.
this Solution has also a Unit Test Project for this Library. This Test Project has a Test which will succeed and one Test which will fail.
Now i want to upload this to github and it should Run the Test Project. But i cant figure out, how i can run the Test Project. All Tutorials are for .NET Core 5+
my actual workflow file looks like this:
name: .NET Framework Desktop
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
strategy:
matrix:
configuration: [Release]
runs-on: self-hosted # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
env:
Solution_Name: SelfHostedPDMTest.sln # Replace with your solution name, i.e. MyWpfApp.sln.
Test_Project_Path: TestProjectTest.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package.
Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj.
steps:
- name: Checkout
uses: actions/checkout#v3
with:
fetch-depth: 0
# Install the .NET Core workload
- name: Install .NET
uses: actions/setup-dotnet#v2
with:
dotnet-version: 5.0.x
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild#v1.0.2
# Execute all unit tests in the solution
- name: Execute unit tests
run: dotnet test
# Restore the application to populate the obj folder with RuntimeIdentifiers
- name: Restore the application
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}
Appx_Bundle_Platforms: x86|x64
Appx_Package_Build_Mode: StoreUpload
This is a sample Workflow from github.
i know the selected .net version is 5.0.x but 4.8.x is not possible.
and also dotnet test would run a .NET Core Test and not a .NET Framework Test.
Maybe someone has a good workflow file or can help me to start?
Try the below as documented
- name: Run vstests
uses: microsoft/vstest-action#v1.0.0
with:
testAssembly: TestProject.dll
searchFolder: .\TestProject\bin\Debug\
runInParallel: true
i have a github project which i'm trying to intergrate in to Travis CI. i'm really new to this. so on my travis.yml i have added like this
language: csharp
solution: MigrationRunner.sln
install:
- nuget restore MigrationRunner.sln
- nuget install NUnit.Runners -Version 3.4.1 -OutputDirectory $TRAVIS_BUILD_DIR/libs
script:
- xbuild /p:Configuration=Release MigrationRunner.sln
- mono $TRAVIS_BUILD_DIR/libs/NUnit.Runners.3.4.1/tools/nunit-console.exe $TRAVIS_BUILD_DIR/libs/MigrationRunner.Test/bin/Debug/MigrationRunner.Test.dll
deploy:
provider: releases
api_key: "79bd0a7b6294145bde09c390b2f5c03680c589b1"
file: "MigrationRunner"
skip_cleanup: true
on:
tags: true
and then tried to run travis but it gets error saying
Cannot open assembly
'/home/travis/build/gayan85/MigrationRunner/libs/NUnit.Runners.3.4.1/tools/nunit-console.exe':
No such file or directory.
what was the wrong?
Here is the behavior I'm trying to achieve in AppVeyor
Build the code (stamp AssemblyInfo with 1.2.3.{build})
Test the code
Create the nuget package if the tests passed
Publish the beta package if the package created successfully (1.2.3-beta-{build})
Also make the package available in artifacts.
Ideally when publishing a nuget package it would be published as prerelease. In NuGet, this is done by adding alpha characters to the end of the package version. It is also considered bad practice to overwrite an existing package (indeed, many nuget implementations do not allow this).
AppVeyor does a good job of building and testing software out of github, but I don't seem to be able to control the nuget package version.
Given:
A package with the next semantic version of 1.2.3
I would expect the AppVeyor {version} variable to equate to 1.2.3.{build}
I would expect the nuget package version to equate to 1.2.3-beta-{build}
The first thing I tried was using variables in the {version} box. Apparently this is not allowed. AppVeyor seems to only do variable substitution for {branch} and {build} as part of the {version}. This means I'll have to maintain a separate variable for the semantic version.
The next challenge I ran into is that there's no way to set the nuget package version through the UI. It wants to default to be the same as the AppVeyor build version.
I decided to try creating the package using Powershell after the tests run. This works, but the Nuget Publish step wants to run before the package is created and there doesn't seem to be a way to control the execution order.
I think I'm on the wrong track. I need a conceptual reset.
Here is my appveyor.yml in its current (incorrect) state:
version: 0.1.0.{build}
configuration: Release
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
environment:
packageVersion: 0.1.0
nuget:
account_feed: true
project_feed: true
disable_publish_on_pr: true
before_build:
- ps: nuget restore
build:
verbosity: minimal
artifacts:
- path: '*.nupkg'
name: nuget package
deploy:
- provider: NuGet
api_key:
secure: blahblahblah
artifact: '*.nupkg'
on:
branch: master
on_success:
- ps: >-
$releaseVersion= $env:packageVersion
$buildNumber = $env:APPVEYOR_BUILD_NUMBER
$betaVersion= "$releaseVersion-beta-$buildNumber"
nuget pack Odin.nuspec -version $betaVersion
Get-ChildItem .\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
How do I fix this? Can I get the behavior I want?
You can use PowerShell and AppVeyor API to control version number. I would try composing appveyor.yml as following:
version: 0.1.0.{build}
environment:
packageVersion: 0.1.0
init:
- ps: $env:buildVersion = "$env:packageVersion.$env:appveyor_build_number"
- ps: $env:nugetVersion = "$env:packageVersion-beta-$env:appveyor_build_number"
- ps: Update-AppveyorBuild -Version $env:buildVersion
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '$(buildVersion)'
assembly_file_version: '$(buildVersion)'
assembly_informational_version: '$(nugetVersion)'
configuration: Release
nuget:
account_feed: true
project_feed: true
disable_publish_on_pr: true
before_build:
- nuget restore
build:
verbosity: minimal
after_build:
- nuget pack Odin.nuspec
artifacts:
- path: '*.nupkg'
deploy:
- provider: NuGet
api_key:
secure: blahblahblah
artifact: '*.nupkg'
on:
branch: master