travis build fails running msbuild due to MSB4019 - msbuild

I am trying to build automatically a golang project in a windows environment with travis and to package the .exe making use of msbuild and wix.
The very same configuration works with Github actions and therefore I believe that both the .wixproj and the wxs are correct and there is some issue with the configuration of msbuild in the travis installation, but I have no more clues.
Possibly the msbuild installed by travis does not include the required wix toolset, I tried to install them, however while creating the package the error persist
The error
C:\Users\travis\gopath\src\github.com\gallo-cedrone\nri-elasticsearch\pkg\windows\nri-amd64-installer\nri-installer.wixproj" (default target) (1) ->
C:\Users\travis\gopath\src\github.com\gallo-cedrone\nri-elasticsearch\pkg\windows\nri-amd64-installer\nri-installer.wixproj(34,5):
error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\WiX\v3.x\Wix.targets" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
.travis
...
- os: windows
env:
- MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
before_script:
- powershell Install-WindowsFeature Net-Framework-Core
- cinst -y wixtoolset
script:
- export PATH=$MSBUILD_PATH:$PATH
- go test ./src/
- go build -v -o ./target/bin/windows_amd64/nri-elasticsearch.exe ./src/
- msbuild.exe -version
- cd ./pkg/windows/nri-amd64-installer/ ; pwd ; env ; msbuild.exe ./nri-installer.wixproj
...
travis job logs

I found a solution thanks to enter link description here
Basically I was installing the wixtools, however the installation folder was not the expected one by vs2017.
It can be fixed simply by changing:
<Import Project="$(WixTargetsPath)" />
with:
<Import Project="$(WixTargetsPath)" Condition=" '$(WixTargetsPath)' != '' " />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets" Condition=" '$(WixTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets') " />
and removing the WixTargetsPath clouses contitions.

Related

Can cmake --build use msbuild instead of devenv

I'm using CMake 3.23 with Visual Studio 2022. From everything I found about cmake --build command it should be running msbuild, but evidently it's running devenv instead. Is there some setting I'm not aware of? How do I get it to run msbuild so I can pass options to it?
This is my generator command:
cmake -G "Visual Studio 17" -A x64 -T v143 ..
And then cmake --build is running devenv instead of msbuild:
cmake --build . --config Release -- /verbosity:detailed
Microsoft Visual Studio 2022 Version 17.2.3.
Copyright (C) Microsoft Corp. All rights reserved.
Invalid Command Line. Unknown Switch : verbosity:detailed.
Use:
devenv [solutionfile | projectfile | folder | anyfile.ext] [switches]
CMake by default is using MSBuild and falls back to devenv if you either requested it deliberately (with CMAKE_MAKE_PROGRAM) or you have an Intel Fortran project in which case it has to use devenv.
You can check if it found MSBuild by checking the CMAKE_VS_MSBUILD_COMMAND variable. And you can force CMake to use MSBuild by setting CMAKE_MAKE_PROGRAM to the MSBuild path (although I don't know how it will behave if you have a Fortran project).

How can I add directory with long name files (more 260 symbols) to CMake CPack NSIS win installer?

I try to add big directory with long paths to CMake CPack NSIS win installer and have error related with long paths
CMake part:
install(
DIRECTORY src/dir_with_long_file_paths
DESTINATION dest
)
cmd line cpack message:
cpack -C Release
CPack: Create package using NSIS
CPack: Install projects
CPack: - Install project: Project
CPack: Create package
CPack Error: Problem running NSIS command: "C:/Program Files (x86)/NSIS/makensis.exe" "C:/GitLabRunner/builds/fe33718a/0/Company/Project/build/_CPack_Packages/win64/NSIS/project.nsi"
Please check C:/GitLabRunner/builds/fe33718a/0/Company/Project/build/_CPack_Packages/win64/NSIS/NSISOutput.log for errors
CPack Error: Problem compressing the directory
CPack Error: Error when generating package:
NSIS error message:
File: failed opening file "C:/Repo/NameOfInstallProgram/build/_CPack_Packages/win64/NSIS/Project\dest\dir1\dir2\dir3\dir4\dir5\dir6\dir7\dir8\dir9\dir10\file_with_very_long_name_bla_bla_bla.bla"
This is probably not an issue with NSIS itself, but a Windows limitation. Have you tried enabling long paths in Powershell?
New-ItemProperty `
-Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" `
-Name "LongPathsEnabled" `
-Value 1 `
-PropertyType DWORD `
-Force
Further reading: Maximum Path Length Limitation
I fixed my issue to add 7z archive to installer and unpack it after installation . For unpack it I used Nsis7z plugin (when use plugins don`t forget about versions (ansi or unicode)).

MSBUILD publish ERROR_USER_UNAUTHORIZED

Summary
I'm using a 9.2.0 Gitlab's CI multirunner on a Windows Server 2016. On a step where I publish ASP.NET project through MSBUILD I've got an authentication error ERROR_USER_UNAUTHORIZED from IIS. But when I use a CMD window on a build machine there I run the same command for publish - everything is published. Doesn't matter if I used a SYSTEM or an ADMINISTRATOR account.
Steps to reproduce
Setup IIS publish.
Setup Gitlab's build agent.
Create the Gitlab's YAML build script (see below).
Run the build.
Actual behavior
On a publish step I've got the ERROR_USER_UNAUTHORIZED error.
Expected behavior
On a publish step I've got my ASP.NET published to a server.
Relevant logs and/or screenshots
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(4292,5): msdeploy error ERROR_USER_UNAUTHORIZED: Не удалось выполнить задачу Web Deploy. (Выполнено подключение к удаленному компьютеру ("192.168.1.66") с использованием службы веб-управления, но не удалось авторизовать. Убедитесь, что вы используете правильные имя пользователя и пароль, что существует сайт, к которому выполняется подключение, и что учетные данные представляют пользователя, у которого есть разрешения на доступ к сайту. Дополнительные сведения: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.) [C:\Gitlab_Build_Agents\1\builds\2378ccf8\0\rushydro\aisa\Sources\Mvc\Mvc.csproj]
Environment description
I'm using a shared Runner (gitlab-ci-multi-runner-windows-386, version 9.2.0) on a Windows 2016. MSBUILD is a part of a Microsoft Visual Studio 2017.
YAML script
variables:
solution: Sources\Faso.sln
msbuild: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
nunit: C:\NUnit\NUnit.Framework-3.7.0\bin\net-4.5\nunitlite-runner.exe
nuget: C:\NuGet\nuget.exe
before_script:
- echo Setting encoding...
- echo %solution%
- echo Restoring NuGet packages...
- '"%nuget%" restore "%solution%"'
stages:
- build-test
- deploy-5023
build-test:
stage: build-test
script:
- chcp 65001
- echo Building...
- '"%msbuild%" "%solution%" /t:Build /p:Configuration=Release /p:TargetFramework=v4.5.2'
- echo Testing...
- dir /s /b *.Tests.dll | findstr /r Tests\\*\\bin\\ > testcontainers.txt
- 'for /f %%f in (testcontainers.txt) do "%nunit%" "%%f"'
except:
- tags
deploy-5023:
stage: deploy-5023
script:
- chcp 65001
- echo Deploying...
- '"%msbuild%" "%solution%" /p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:MsDeployServiceUrl=https://192.168.1.66:8172/msdeploy.axd /p:username=user /p:password=password /p:Configuration=Release /p:TargetFramework=v4.5.2 /p:AllowUntrustedCertificate=True /p:DeployIisAppPath=Faso /p:MSDeployPublishMethod=WMSVC /p:SkipExtraFilesOnServer=True /p:ExcludeFilesFromDeployment="Web.config;ConnectionStrings.config;system.config"'
when: manual
except:
- tags
artifacts:
expire_in: 1 week
paths:
- Sources\Mvc\App_Data\
- Sources\Mvc\bin\
- Sources\Mvc\Content\
- Sources\Mvc\favicon.ico
- Sources\Mvc\Global.asax
- Sources\Mvc\Web.config
Solved by changing the arguments' order and format for MSBUILD.
- '"%msbuild%" "%solution%" /p:DeployOnBuild=True;Username=username;Password=password;DeployTarget=MSDeployPublish;MsDeployServiceUrl=https://192.168.1.66:8172/msdeploy.axd;Configuration=Release;TargetFramework=v4.5.2;AllowUntrustedCertificate=True;DeployIisAppPath=Faso;MSDeployPublishMethod=WMSVC;SkipExtraFilesOnServer=True;ExcludeFilesFromDeployment="Web.config;ConnectionStrings.config;system.config"'

How to set up and build Apache 2.4 on WINDOWS 7 Pro?

I have a project, and need to set up and build an Apache24 server on windows, but there is almost non of information on that, can you give some advice?
I had to build and install Expat to get Apache running on windows 10 x64 with the instructions above. I build on Windows Visual Studio 2017 Community Edition using the x64 Native Command Prompt. (I installed all the VC and C++ modules - not sure which ones were specifically required.) Also i used the latest version of all of the software listed above so the install commands had to be adjusted accordingly. Trial by fire! Good luck.
I found the answer, after a lot of searching, I found an acceptable way to do it.
Software Requirements:
Visual Studio 2013 (I use the Community Edition)
Make a folder on C, call it BuildTools and install all the following programs there:
ActivePerl for Windows (64-bit, currently using 5.20.1.2000)
CMake for Windows (currently using 3.1.3)
GNU Awk for Windows (currently using 3.1.6-1)
GnuWin32 (any version from 2014+)
Netwide Assembler (NASM) (currently using 2.11.06)
Source Code Packages (I don't use ZLIB for Apache or OpenSSL, or LUA/LIBXML2/EXPAT, therefore these are not included in the process):
httpd-2.4.12.tar.gz
apr-1.5.1.tar.gz
apr-util.1.5.4.tar.gz
openssl-1.0.2a.tar.gz (yes it works with 1.0.2a!)
pcre-8.36.tar.gz
Here are the steps:
Extract all packages into their separate folders in your preferred source tree (e.g. C:\Development\Apache24\src)
Create custom build folders for Apache, PCRE, APR and APR-Util in your preferred build folder (e.g. C:\Development\Apache24\build
Your folder structure should resemble the below:
Make the following file changes so that ApacheMonitor gets built (without the Manifest error):
C:\Development\Apache24\src\httpd-2.4.12\CMakeLists.txt
Uncomment the section to build the ApacheMonitor utility (lines 769-775)
Find the following lines below, they will be in comments
# getting duplicate manifest error with ApacheMonitor
ADD_EXECUTABLE(ApacheMonitor support/win32/ApacheMonitor.c support/win32/ApacheMonitor.rc)
SET(install_targets ${install_targets} ApacheMonitor)
SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/ApacheMonitor.pdb)
SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES WIN32_EXECUTABLE TRUE)
SET_TARGET_PROPERTIES(ApacheMonitor PROPERTIES COMPILE_FLAGS "-DAPP_FILE -DLONG_NAME=ApacheMonitor -DBIN_NAME=ApacheMonitor.exe / ${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(ApacheMonitor ${EXTRA_LIBS} ${HTTPD_SYSTEM_LIBS} comctl32 wtsapi32)
Also
C:\Development\Apache24\src\httpd-2.4.12\support\win32\ApacheMonitor.rc
Comment out the line that includes ApacheMonitor.manifest (line 29)
//CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "ApacheMonitor.manifest"
4.1 Create a set_path.bat file with the following code:
SET VC_HOME=c:\Program Files (x86)\Microsoft Visual Studio 13.0\VC
call VC_HOME\vcvarsall amd64
SET BUILD_ROOT=C:\BuildTools
SET PATH=%PATH%;%BUILD_ROOT%\cmake\bin
SET PATH=%PATH%;%BUILD_ROOT%\gawk\bin
SET PATH=%PATH%;%BUILD_ROOT%\nasm
SET PATH=%PATH%;%BUILD_ROOT%\perl\bin
You will need to run that file later in the process.
From the Start menu, launch the VS2013 x64 Native Tools Command Prompt found under Visual Studio 2013->Visual Studio Tools. Alternatively, but not recommended, from a Windows Command Prompt.
5.1 Go to GnuWin32, find his lib and the include folder, and copy their content to the BuildTools/perl/lib folder, this should resolve some errors that came up in the process while I was doing this
5.2 This step, you can skip now, BUT, if there is an error that includes the expat.h and the expath_external.h files, Find an older version of Apache, and copy its expat_external.h to the apache24/include folder
Find expat.h file on this site
https://github.com/apache/apr-util/blob/0.9.x/xml/expat/lib/expat.h
copy its content over the file, you find in apache24/include folder Find an older version of Apache (don't know exactly witch version), and copy its expat_external.h to the apache24/include folder
Find expat.h file on this site
https://github.com/apache/apr-util/blob/0.9.x/xml/expat/lib/expat.h
copy its content over the file, you find in apache24/include folder
5.3. Find the set_path.bat folder from the console and run it.
this you need to do, to be able to run the next steps
Navigate into the build sub-folder for PCRE, run CMAKE to generate a suitable Makefile, then compile and install
cd /D C:\Development\Apache24\build\pcre
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DPCRE_BUILD_TESTS=OFF -DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_SUPPORT_PCREGREP_JIT=OFF -DPCRE_SUPPORT_UTF=ON -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_NEWLINE=CRLF -DINSTALL_MSVC_PDB=OFF ..\..\src\pcre-8.36
nmake
nmake install
Navigate into the source sub-folder for OpenSSL, configure the build environment for compiling with NASM, then compile and install
cd /D C:\Development\Apache24\src\openssl-1.0.2a
perl Configure VC-WIN64A --prefix=C:\Apache24 --openssldir=C:\Apache24\conf enable-camellia no-idea no-mdc2 no-ssl2 no-ssl3 no-zlib
ms\do_win64a.bat
nmake /f ms\ntdll.mak
nmake /f ms\ntdll.mak install
Navigate into the build sub-folder for APR, run CMAKE to generate a suitable Makefile, then compile and install
cd /D C:\Development\Apache24\build\apr
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMIN_WINDOWS_VER=0x0600 -DAPR_HAVE_IPV6=ON -DAPR_INSTALL_PRIVATE_H=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..\..\src\apr-1.5.1
nmake
nmake install
Navigate into the build sub-folder for APR-Util, run CMAKE to generate a suitable Makefile, then compile and install
cd /D C:\Development\Apache24\build\apr-util
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DOPENSSL_ROOT_DIR=C:\Apache24 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DAPU_HAVE_CRYPTO=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..\..\src\apr-util-1.5.4
nmake
nmake install
Navigate into the build sub-folder for Apache, run CMAKE to generate a suitable Makefile, then compile and install
cd /D C:\Development\Apache24\build\httpd
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=C:\Apache24 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..\..\src\httpd-2.4.12
nmake
nmake install
Finally, confirm everything is working
cd /D C:\Apache24\bin
openssl version
httpd -V
These are the steps and the problems I encountered, and I followed the steps from this site:
https://www.apachelounge.com/viewtopic.php?t=6462
Also I added a few more steps and solutions that I needed to do to make it work.
I hope this will help someone else in the future.

AppVeyor build error MSB3774: Could not find SDK "Microsoft.AdMediator.Universal"

I am getting this MsBuild error when trying to build my Universal Windows Platform (UWP) application with AppVeyor:
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2048,5): error MSB3774: Could not find SDK "Microsoft.AdMediator.Universal, Version=1.0". [C:\projects\santasegameengine\Source\UI\Santase.UI.WindowsUniversal\Santase.UI.WindowsUniversal.csproj]
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(2048,5): error MSB3774: Could not find SDK "Microsoft.Advertising.Xaml, Version=10.0". [C:\projects\santasegameengine\Source\UI\Santase.UI.WindowsUniversal\Santase.UI.WindowsUniversal.csproj]
Here is the full build log: https://ci.appveyor.com/project/NikolayIT/santasegameengine/build/1.0.252
And here is the source code of the app in GitHub: https://github.com/NikolayIT/SantaseGameEngine/tree/master/Source/UI/Santase.UI.WindowsUniversal
How can I fix such an error?
Adding this as PS (PowerShell) script (as before build script) fixed the problem for me:
Here is the script:
Write-Host "Installing Microsoft Universal Ad Client SDK..."
$msiPath = "$($env:USERPROFILE)\AdMediator.msi"
(New-Object Net.WebClient).DownloadFile('https://visualstudiogallery.msdn.microsoft.com/401703a0-263e-4949-8f0f-738305d6ef4b/file/146057/6/AdMediator.msi', $msiPath)
cmd /c start /wait msiexec /i $msiPath /quiet
Write-Host "Installed" -ForegroundColor green
And the result: