How to set pipeline for building unity project in azure devOps - c#

I am new in creating pipelines and I need to create one to build my unity project and C# scripts. I try this:
https://dinomite-studios.github.io/unity-azure-pipelines-tasks/hosted-agent.html (in this try I have not Unity Active License serial key and because of that I remove this task, but my second PowerShell script doesn't pass) for this I get this error:
Starting: PowerShell Script
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Linux, macOS, or Windows
Version : 2.170.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\2178f08e-dbac-43f8-a053-1a2420d6c47c.ps1'"
Find-UnitySetupInstaller : The term 'Find-UnitySetupInstaller' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At D:\a\_temp\2178f08e-dbac-43f8-a053-1a2420d6c47c.ps1:3 char:41
+ ... tall-UnitySetupInstance -Installers (Find-UnitySetupInstaller -Versio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Find-UnitySetupInstaller:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
##[error]PowerShell exited with code '1'.
Finishing: PowerShell Script
and this:
https://medium.com/medialesson/continuous-integration-for-unity-3d-projects-using-azure-pipelines-e61ddf64ad79 for this I get this error:
Starting: Unity Build Android
==============================================================================
Task : Unity Build
Description : Build a Unity project and get the exported output files.
Version : 3.1.1
Author : Dinomite Studios
Help : Builds a Unity project to supported build target platforms. [More Information](https://github.com/Dinomite-Studios/unity-azure-pipelines-tasks)
==============================================================================
Determining Unity editor version for project at D:\a\1\s\virtualterminal-realwear\VirtualTerminal
Success, Unity editor version found 2019.3.9f1, alpha=false, beta=false
Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.
Finishing: Unity Build Android
and I try with only "VisualStudioBuild" Task, but nothing doesn't work.
Can someone tell me how to do it right?

Find-UnitySetupInstaller : The term 'Find-UnitySetupInstaller' is not
recognized as the name of a cmdlet, function, script file, or operable
program.
For the first error your encountered, if you check the log of first Powershell task, you will find one warning message: WARNING: User declined to install module (UnitySetup). In another word, the module UnitySetup is not installed successfully even the task is pass with green. Our Azure devops system refuse to install this module.
That's why you encountered the cmdlet xxx is not recognized error. That's because the parent module UnitySetup has not installed successfully yet.
To resolve this issue, Need to append -Force parameter after the Install-module command in first Powershell task:
Install-Module UnitySetup -AllowPrerelease -Scope CurrentUser -Force
##[error]Unable to locate executable file: 'C:\Program Files\Unity\Hub\Editor\2019.3.9f1\Editor\Unity.exe'.
According to the second log you shared, you are using Hosted agent, right? And seems also you didn't add Unity Get Project Version task and Powershell tasks to install Unity tool into environment since you were following the pipeline definition sample of this blog.
If you review that blog carefully, you will find that the blog author has pre-installed the self agent on local machine manually before he configured the pipeline in Azure devops, along with Unity Hub installed on the agent.
In short, the Unity.exe has been exists in author's building environment, so the installing Unity steps with Powershell scripts omitted here. BUT our Hosted agent has not installed this executable file in our machine, which means you must install it by yourself when you are using Hosted agent.
Per my opinion, I strongly suggest you to follow the second blog you mentioned to configure your pipeline which can save your build execution time:
1) Install self agent first.
2) Install Unity.exe and needed unity version.
3) Configure pipeline.

Related

APPAP308E - Invalid process path. Full path is required

I use CyberArk 12.1 to get database password by SDK. Application was written in NetCore3.1, we migrate it to NET6. Sadly CA 12.1 isn't compatible with NET6, support appears in 12.6, but my organisation at this moment doesn't plan upgrade
I try to execute PowerShell script from my application (NET6) to connect with CyberArk agent
Script returns from CA error
APPAP308E - Invalid process path. Full path is required
PowerShell
C:\Program Files (x86)\...\CLIPasswordSDK.exe GetPassword /p AppId=xxx /p Query="Safe=xxx;Folder=Root;Object=xxx" /p Reaseon="test"
I don't understand what means path in this context?
How can I resolve problem, what could be wrong in my script?
Script is executed in application by creating new process
Process.Start("script.bat"); // Error about path from CyberArk
There has to be entered absolute path
Process.Start("c:\\app\\script.bat"); // works

Why using MSBuild via VS Developer Console works fine, but via powershell it wants me to install Windows SDK?

When I'm compiling project via PowerShell:
PS C:\Windows\Microsoft.NET\Framework64\v4.0.30319> .\MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj"
then it fails
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(2015,5): error MSB3091:
ask failed because "AxImp.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "AxImp.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK. 2) Install Visual Studio 2010. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the "ToolPath" parameter of the task."
but when I do it via VS Developer Command Prompt for VS2019
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.4.3
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
C:\Windows\System32>MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj"
then it works perfectly fine!
But, as you see Current Path (folder of MS Build) is quite different, so I tried executing this in PowerShell once again with VS Dev CMD's location:
PS C:\Windows\System32> cd "C:\Windows\System32"
PS C:\Windows\System32> MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj"
MSBuild.exe : The term 'MSBuild.exe' is not recognized as the name of a cmdlet, function, script file, or operable prog
ram. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ MSBuild.exe "C:\Users\Me\repo\Proj\App.csproj" ...
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (MSBuild.exe:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Windows\System32>
What's going on? Why I can compile my projects perfectly fine from Developer CMD meanwhile I cannot do it with Power Shell and it screams that I do not have Windows SDK?
Or which MS Build (apparently there's a few of them) should I use?
I found that using MSBuild from:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe"
works fine, so apparently VS Dev CMD is using different MSBuild than the one that lies in C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Case solved (for me)

dotnet-sonarscanner - fails on post-processing - "Could not find or load main class"

trying to get the sonar scanner running from the command line at the moment with just msbuild.exe solution.sln /rebuild it's currently failing on the post-processing step and i can't seem to get beyond that
my java path is set in: C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe. I tried updating my path to a location that didn't have any spaces in it but no luck.
I also tried using dotnet sonar scanner and msbuild sonar scanner. both with the same result
These are the steps i'm executing:
dotnet-sonarscanner begin /k:"key" /d:sonar.host.url="https://my_company_sonarqube.com" /d:sonar.login="token" /d:sonar.verbose=true
MSBuild.exe solution.sln /t:Rebuild /p:Platform="Any CPU"
dotnet-sonarscanner end /d:sonar.login="token"
Everything seems to work fine until i get to the post-processing step:
Executing file C:\Users\userid\.dotnet\tools\.store\dotnet-sonarscanner\4.7.1\dotnet-sonarscanner\4.7.1\tools\netcoreapp2.1\any\sonar-scanner-4.1.0.1829\bin\sonar-scanner.bat
Args: -Dsonar.scanAllFiles=true -Dproject.settings=C:\Users\userid\Documents\project_path\.sonarqube\out\sonar-project.properties --embedded --debug <sensitive data removed>
Working directory: C:\Users\userid\Documents\project_path
Timeout (ms):-1
Process id: 38116
Error: Could not find or load main class
Process returned exit code 1
The SonarQube Scanner did not complete successfully
19:53:44.155 Post-processing failed. Exit code: 1
Using the following JDK
java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
ok so i'm not sure why i was getting the main class error. I re-ran everything using the sonarscanner batch script and then with a stripped down java call from the batch script and it seems like my problem was not having my ssl certificates for the sonarqube server.
Starting over and setting SONAR_SCANNER_OPTS seemed to do the trick.
set SONAR_SCANNER_OPTS = "-Djavax.net.ssl.trustStore="C:\path\to\trustStore"

Why is my MSbuild command path not reachable if I change my Azure DevOps agent?

A task of my Azure DevOps build fails to find my solution path when I change from "Hosted" Agent to "Hosted VS2017".
Does the folder organisation change from a agent to another ?
My C# solution used to run with .NET framework 4.6, and I reference now 4.7.1 version. That's why I need apparently to use "Hosted VS2017" agent instead of the default "Hosted" agent.
But a task that uses a gulpfile fails when trying to build my solution. I tried to execute the build with diagnostics, but I got no more informations than "The system cannot find the path specified." in my first MSbuild command.
---
[command]C:\npm\prefix\gulp.cmd CI-default --gulpfile D:\a\1\s\source\back-end\gulpfile.js
[‌15:41:53‌] Using gulpfile D:\a\1\s\source\back-end\gulpfile.js‌
[‌15:41:53‌] Starting 'CI-default'...‌
[‌15:41:53‌] Starting 'Publish-All-Projects'...‌
[‌15:41:53‌] Starting 'Build-Solution'...‌
[‌15:41:53‌] Using automatic maxcpucount‌
The system cannot find the path specified.
[‌15:41:53‌] { Error: Command failed: "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\a\1\s\source\back-end\******.sln" "/target:Build" /verbosity:minimal /toolsversion:14.0 /nologo /maxcpucount /property:Configuration="Release"‌
The system cannot find the path specified.
at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
killed: false,
code: 1,
signal: null,
cmd:
'"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe" "D:\\a\\1\\s\\source\\back-end\\ALE.sln" "/target:Build" /verbosity:minimal /toolsversion:14.0 /nologo /maxcpucount /property:Configuration="Release"' }
---
The build fails at this steps but should execute properly (it does actually when I do it with the default "Hosted" agent or on my local machine with Visual Studio)
Why is my MSbuild command path not reachable if I change my Azure DevOps agent?
That because the Visual Studio 2015 is installed by default on the "Hosted" Agent, and Hosted VS2017 with Visual Studio 2017 by default.
However, the path for the MSBuild 14.0 and 15.0 are different.
The default path for MSBuild 14.0 is C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe.
But the default pathfor the MSBuild 15.0, the path is C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.
So to resolve this issue, you should change the MSBuild in your CMD scripts:
cmd:
'"C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe"
To
cmd:
C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\MSBuild\\15.0\Bin\\MSBuild.exe
Hope this helps.

dotnet restore unable to load shared library 'libproc' or one of its dependencies on Mac OS

I am following the tutorial for .NET on
https://www.microsoft.com/net/learn/get-started/macos
I installed the .NET SDK and create an app by using on macOS High Sierra Version 10.13.5:
~$ dotnet new console -o myApp
which gives me an error of:
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on myApp/myApp.csproj...
Unable to load shared library 'libproc' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES
environment variable: dlopen(liblibproc, 1): image not found
I tried to do
export DYLD_PRINT_LIBRARIES=/usr/lib/
before deleting the created folder and files, and I get a lot of printed statements that look like:
dyld: loaded: /usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.1/System.IO.Compression.Native.dylib
as well as the same error:
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on myApp/myApp.csproj...
Unable to load shared library 'libproc' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES
environment variable: dlopen(liblibproc, 1): image not found
I got it to work by using fs-usage to examine where does dotnet try to find libproc.dylib. In my case, I found that dotnet was trying to find libproc.dylib at ~/libproc.dylib, so I copied /usr/lib/libproc.dylib to ~/libproc.dylib and dotnet worked.
I think this is not a satisfactory answer so if anyone knows why dotnet was not looking for libproc.dylib at /usr/lib/libproc.dylib, please help me out. Thank you!
I noticed that my comment only worked when I started pwsh in ~.
I created a symlink in /usr/local/microsoft/powershell/6 that points to libproc.dylib:
/usr/local/microsoft/powershell/6$ sudo ln -s /usr/lib/libproc.dylib libproc.dylib
PowerShell starts correctly in any directory.
This will likely need to be recreated when I upgrade PowerShell Core (via Homebrew Cask).
** edit **
I should have read the question more closely--it was about dotnet, not pwsh.

Categories

Resources