Trying to use appveyor CI for a C++ project (Makefile) with binding in C# so I would like to be able to run csc.exe from the script line.
According to the doc https://www.appveyor.com/docs/build-environment/#net-framework, I would say csc.exe must be installed somehow in the image.
i.e. need to fill the ???????????? in my .appveyor.yml:
...
environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
...
build:
- set PATH=C:\Python36-x64;%PATH%
- where python.exe
- where /F python.exe | tools\sed.exe -n "/\".*\"/{p;q;}" | tools\sed "s/\"//g"
- set PATH=C:\????????????;%PATH%
- where csc.exe
I got:
$ set PATH=C:\Python36-x64;%PATH%
$ where python.exe
C:\Python36-x64\python.exe
C:\Python27\python.exe
$ where /F python.exe | tools\sed.exe -n "/\".*\"/{p;q;}" | tools\sed "s/\"//g"
C:\Python36-x64\python.exe
$ where csc.exe
INFO: Could not find files for the given pattern(s).
ps: I put python as an example of what I would like to do for csc.exe, fsc.exe and dotnet ....
pps: why sed ? typically I would like a prompt equivalent to bash cmd which (i.e. only return the first one if any)
You can use this in appveyor.yml:
after_build:
- cmd: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat"
csc.exe main.cs
The VsDevCmd.bat file will automatically set the console environment for using MS Build Tools. main.cs is for example. Also you can add cl.exe after/before with csc.exe for both C++/C# projects. See this article Developer Command Prompt for Visual Studio.
you can simply Recursively try to find it !
build:
- where -F -R \ csc.exe
possible output:
$ where -F -R \ csc.exe
"C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Stack5\Packages\Microsoft.Net.Compilers.1.0.0\tools\csc.exe"
"C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\Microsoft.Net.Native.Compiler\1.7.3\tools\arm\ilc\csc\csc.exe"
"C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\Microsoft.Net.Native.Compiler\1.7.3\tools\x64\ilc\csc\csc.exe"
"C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\Microsoft.Net.Native.Compiler\1.7.3\tools\x86\ilc\csc\csc.exe"
"C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\Microsoft.Net.Native.Compiler\2.0.2\tools\csc\csc.exe"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\csc.exe"
then set the path accordingly...
Related
When I tried to call
/// runs and transforms the data 🤖
this._interpreter.run(input, output);
this._interpreter = await Interpreter.fromAsset('mobilefacenet.tflite',
options: interpreterOptions);
Got this error
Failed to load dynamic library 'libtensorflowlite_c.so': dlopen failed: library "libtensorflowlite_c.so" not found
For Windows users:
Copy all these lines on notepad:
#echo off
setlocal enableextensions
cd %~dp0
set TF_VERSION=2.5
set URL=https://github.com/am15h/tflite_flutter_plugin/releases/download/
set TAG=tf_%TF_VERSION%
set ANDROID_DIR=android\app\src\main\jniLibs\
set ANDROID_LIB=libtensorflowlite_c.so
set ARM_DELEGATE=libtensorflowlite_c_arm_delegate.so
set ARM_64_DELEGATE=libtensorflowlite_c_arm64_delegate.so
set ARM=libtensorflowlite_c_arm.so
set ARM_64=libtensorflowlite_c_arm64.so
set X86=libtensorflowlite_c_x86_delegate.so
set X86_64=libtensorflowlite_c_x86_64_delegate.so
SET /A d = 0
:GETOPT
if /I "%1"=="-d" SET /A d = 1
SETLOCAL
if %d%==1 CALL :Download %ARM_DELEGATE% armeabi-v7a
if %d%==1 CALL :Download %ARM_64_DELEGATE% arm64-v8a
if %d%==0 CALL :Download %ARM% armeabi-v7a
if %d%==0 CALL :Download %ARM_64% arm64-v8a
CALL :Download %X86% x86
CALL :Download %X86_64% x86_64
EXIT /B %ERRORLEVEL%
:Download
curl -L -o %~1 %URL%%TAG%/%~1
mkdir %ANDROID_DIR%%~2\
move /-Y %~1 %ANDROID_DIR%%~2\%ANDROID_LIB%
EXIT /B 0
Save the file as install.bat and put the file in root directory of your project.
Open in explorer and open a command window there.
Type install.bat and press Enter. Use install.bat -d (Windows) instead if you wish to use GpuDelegateV2 and NnApiDelegate.
For Linux/Mac users:
Copy all these lines on notepad
#!/usr/bin/env bash
cd "$(dirname "$(readlink -f "$0")")"
# Available versions
# 2.5, 2.4.1
TF_VERSION=2.5
URL="https://github.com/am15h/tflite_flutter_plugin/releases/download/"
TAG="tf_$TF_VERSION"
ANDROID_DIR="android/app/src/main/jniLibs/"
ANDROID_LIB="libtensorflowlite_c.so"
ARM_DELEGATE="libtensorflowlite_c_arm_delegate.so"
ARM_64_DELEGATE="libtensorflowlite_c_arm64_delegate.so"
ARM="libtensorflowlite_c_arm.so"
ARM_64="libtensorflowlite_c_arm64.so"
X86="libtensorflowlite_c_x86_delegate.so"
X86_64="libtensorflowlite_c_x86_64_delegate.so"
delegate=0
while getopts "d" OPTION
do
case $OPTION in
d) delegate=1;;
esac
done
download () {
wget "${URL}${TAG}/$1" -O "$1"
mkdir -p "${ANDROID_DIR}$2/"
mv $1 "${ANDROID_DIR}$2/${ANDROID_LIB}"
}
if [ ${delegate} -eq 1 ]
then
download ${ARM_DELEGATE} "armeabi-v7a"
download ${ARM_64_DELEGATE} "arm64-v8a"
else
download ${ARM} "armeabi-v7a"
download ${ARM_64} "arm64-v8a"
fi
download ${X86} "x86"
download ${X86_64} "x86_64"
Save the file as install.sh name and put the file in root directory of your project.
Open a command window there.
Type sh install.sh and press Enter. Use sh install.sh -d instead if you wish to use GpuDelegateV2 and NnApiDelegate.
You need to add a file in the root directory in the app found in
tflite_flutter package. tflite_flutter. You can also find it here.
just download the file and place it into the root directory in your app and double click to install the needed information. (For Windows)
I had the same error. Hopefully this is helpful to someone.
After using the install.sh file, that error showed (only on Android, iOS worked fine). But I had changed the wget to curl in the install file and it had downloaded a redirect html page.
The replacement that worked for me was:
# wget "${URL}${TAG}/$1" -O "$1" # Replaced with the below line
curl -L "${URL}${TAG}/$1" -o "$1"
Try to confirm that the files you have downloaded are the correct files. You can inspect these files in <projectdirectory>/android/app/src/main/jniLibs. They should be binary files that begin with ^?ELF, not html files like what I had.
I am using Azure Pipelines to build a Rakudo binary for Raku (previously aka Perl 6) in Windows.
This is my azure-pipelines.yml file:
jobs:
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- bash: |
mkdir -p $(Build.SourcesDirectory)/rakudo-win
curl -L https://github.com/rakudo/rakudo/releases/download/2019.07.1/rakudo-2019.07.1.tar.gz | tar xz
mv rakudo-2019.07.1 rakudo
cd rakudo
C:/Strawberry/perl/bin/perl Configure.pl --gen-moar --gen-nqp --backends=moar --prefix=$(Build.SourcesDirectory)/rakudo-win
make
make install
- bash: |
echo "##vso[task.prependpath]$(Build.SourcesDirectory)/rakudo-win/bin"
- bash: |
perl6 -v
The pipeline script builds perl6 binary fine inside $(Build.SourcesDirectory)/rakudo-win/bin folder. There is indeed perl6.exe inside $(Build.SourcesDirectory)/rakudo-win/bin. To make it available, I set the path by prepending it in the bash script. But when I try to run command perl6 -v, the build fails at this step.
I searched for similar issues in SO here, here, here.
Still I could not solve my issue. Any help how to make perl6 binary available at PATH?
EDITED
Next thing I did was create another .yml script as follows:
jobs:
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- script: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
- pwsh: |
mkdir -p C:\rakudo-win
Invoke-WebRequest -Uri "https://github.com/rakudo/rakudo/releases/download/2019.07.1/rakudo-2019.07.1.tar.gz" -OutFile "rakudo.tar.gz"
tar -xvf .\rakudo.tar.gz
cd rakudo-2019.07.1
C:\Strawberry\perl\bin\perl Configure.pl --gen-moar --gen-nqp --backends=moar --prefix=C:\rakudo-win
make
make install
- pwsh: |
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
$newpath = "C:\rakudo-win\bin;$oldpath"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newpath
- script: |
SET PATH=C:\rakudo-win\bin;%PATH%
- script: |
perl6 -v
and tried changing PATH twice once in powershell and another in cmdline. But still it throws following error:
'perl6' is not recognized as an internal or external command,
operable program or batch file.
Any help?
The best method I have found for setting the PATH for subsequent tasks in Azure Pipelines is by using the logging command syntax mentioned in the first of the three SO links you looked at. Since you are using PowerShell in your updated yaml pipeline, the command would be:
Write-Host "##vso[task.prependpath]$(Build.SourcesDirectory)/rakudo-win/bin"
Note that this only applies to subsequent tasks, if you try outputting the PATH variable in the current task it will not have updated.
In fact, you are very close to the correct solution. Your second powershell task has set the PATH successfully. You can add another separate task to print out the system PATH value to verify this.
- pwsh: |
$NewPathInRegistry = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
Write-Host $NewPathInRegistry
To set the PATH programmatically, you can not use set command, this command can indeed set the environment variable PATH, but the disadvantage of set is the new PATH value is only available in the current command line terminal, it does not actually been added into the System Variable. That's why you were getting an unrecognized error in the next script step.
To permanently add the directory to environment variable PATH so that it can work for next others steps, you need use setx or add them into Registry by using reg add. But the usage of setx has limitation that the PATH value max to 1024 characters. So, here the best solution is updating PATH by modifying the Registry value.
BUT, updating Registry still has another issue, you must kill current process and run one new process to run perl6 so that it can read the new available Registry setting.
If run stop-process in Azure devops pipeline, it will make the task failed with exit code -1. This is the expected exit code, so you can set the continueOnError: true to step so that the next steps can continue.
why not just do this:
- script: |
PATH=$BUILD_SOURCESDIRECTORY/rakudo-win/bin:$PATH perl6 -v
I'm working through a coding tutorial/book called Curious Moon. One of the assignments is to normalize and load data from a CSV file put in a Postgres table. The database name is "enceladus" and the table name is "master_plan". I was told to use make to do this. I can't figure out how to run the Makefile in PowerShell.
I installed GNUWin32 with make.exe on my Windows laptop running Windows 10. I used PowerShell to run make.exe. I did this by running notepad $profile and saved New-Item alias:make -Value 'C:\Program Files (x86)\GnuWin32\bin\make.exe' in the file. I gave it a new alias because I was getting an error message. Now when I'm calling the alias like this:
PS C:\Users\Sabrina> make
I'm getting this error:
make: *** No targets specified and no makefile found. Stop.
I wrote the Makefile in sublime and saved it as a makefile extension. It's in the same folder 'C:\Program Files (x86)\GnuWin32\bin' as make.exe and named Makefile. I tried running it as
PS C:\Users\Sabrina> make -f Makefile
and then I get the error
make: Makefile: No such file or directory
I'm not sure how to get the makefile to open and run.
This is my code in the Makefile:
DB=enceladus
BUILD=${CURDIR}/build.sql
SCRIPTS=${CURDIR}/scripts
CSV='${CURDIR}/data/master_plan.csv'
MASTER=$(SCRIPTS)/import.sql
NORMALIZE = $(SCRIPTS)/normalize.sql
all: normalize
psql $(DB) -f $(BUILD)
master:
#cat $(MASTER) >> $(BUILD)
import: master
#echo "COPY import.master_plan FROM $(CSV) WITH DELIMITER ',' HEADER CSV;" >> $(BUILD)
normalize: import
#cat $(NORMALIZE) >> $(BUILD)
clean:
#rm -rf $(BUILD)
Makefile is in C:\Program Files (x86)\GnuWin32\bin, but you're current working directory is C:\Users\Sabrina. When running make or make -f Makefile the command is looking for a Makefile in the current working directory, not in the directory where the executable resides.
Put the Makefile into your current working directory and the problem will disappear.
Move-Item 'C:\Program Files (x86)\GnuWin32\bin\Makefile' .
make
I just downloaded a file which was hidden as a shortcut to powershell. I'm not sure what code it has just executed as it looks cryptic. This is what the .lnk file target was configured to:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoPr -WINd 1 -eXEc ByP & ( $PsHoME[21]+$PShOmE[34]+'X') (( '73-69%88-40j78P101P119z45U79-98U106%101-99s116r32-83P121P115j116x101x109r46x78U101-116z46j87z101x98x67j108U105-101P110j116D41x46r68U111s119
It was set to start in:
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0
This might sound silly but I have been trying to execute a NUnit test using powershell script, had several attempts but no hope. is there different format or do I need to add a plugin?
Any help would be appriciated...
Command = "c:\Program Files\NUnit 2.4.8\bin\nunit-console.exe" /config=Release "C:\projects\IntegrationTests\IntegrationTests.nunit" 2>&1
Output as below:
PS C:\tests> "c:\Program Files\NUnit2.4.8\bin\nunit-console.exe" /config=Release
"C:\projects\IntegrationTests\IntegrationTests.nunit" 2>&1
You must provide a value expression on the right-hand side of the '/' operator.
At line:1 char:55 + "c:\Program Files\NUnit 2.4.8\bin\nunit-console.exe" / <<<<
config=Release "C:\projects\IntegrationTests\IntegrationTests.nunit" 2>&1
Thanks in Advance
You didn't put the part
/config=Release
inside your quoted command text.
Your command should probably look like
"c:\Program Files\NUnit 2.4.8\bin\nunit-console.exe /config=Release C:\projects\IntegrationTests\IntegrationTests.nunit" 2>&1
... i didn't check nunit-console.exe command line options, but i suppose you already tested if the nunit command works.
Sorry for the mess in the top dialog, proper code version below
& 'c:\Program Files\NUnit 2.4.\bin\nunitconsole.exe' /config=Release C:\Projects\IntegrationTests\IntegrationTests.nunit 2>&1