MSBuild + Qt Vs Tool failed to include Qt on Jenkins - visual-studio

I am not able to build a Qt application using MSBUILD and Qt VS Tools on Jenkins.
I have created a dummy Qt application using Visual Studio (new project -> Qt -> Qt Widget Application) (https://github.com/ThomArmax/dummy-qtvstool260-test-app) which I can build and run on my desktop. But I can make it build on my Jenkins server.
Context
Visual Studio 2017 15.9.14
Qt 5.12.8 msvc2017 64 bits
Qt VS tools 2.6.0
Here is my Jenkins build script
set QTDIR=%QTMSVC2017_64%
%MSBUILD_VS2017% /t:rebuild /p:Platform=x64 /p:Configuration=Release QtWidgetsApplication1.sln
And the build output
dummy-qtvstool260-test-app\qtwidgetsapplication1\stdafx.h(1): fatal error C1083:'QtWidgets.h: No such file or directory
I have tried with different Qt version. Of course, I can manually add the necessary include paths, but I guess that should not be necessary. More over, it does not guaranty that I won't have other issues. I suspect a Qt Vs Tool issue.
I have also tried to define the QtMsBuild env variable to %LOCALAPPDATA%\QtMsBuild without success.
Does any of you guys had the same issue ?
Thanks by advance

Ok, I have figured out why. Fist, on the server, the QtMsBuild was not updated ... Then we used the amd64 version of MSBUILD, if I use the 32 bits version, it works fine !
See https://bugreports.qt.io/browse/QTVSADDINBUG-828

Related

Xamarin.forms project in Mac terminal without Visual Studio

I'm trying to build a job for Xamarin.forms project in mac terminal without UI method. but, not sure which are the tools are mandatory to be installed. Could anyone help here ?
Installed : Dotnet Core 6 version of visual studio SDK
Build need to be fully in terminal(mac-command line)
Need to do without visual studio application
Why not try build the app from the command line using MSBuild and see what errors it gives you. That way, you can find out what's missing and add things until it builds.
I'm using this command to build my apps from Windows (you may need to change a few things on Mac):
"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\msbuild.exe" C:\Projects\MyApp\src\MyApp\MyApp.iOS\MyApp.iOS.csproj /p:Platform=iPhone /p:BuildIpa=true /p:IpaPackageDir=C:\Projects\MyApp\artifacts\App_iOS /p:IpaPackageName=MyApp.ipa /p:ServerAddress=192.168.0.23 /p:ServerUser="Username" /p:ServerPassword=123456SafePassword /p:ContinueOnDisconnected=false /p:Configuration=Release /restore /target:Build /verbosity:Normal
Here's some useful info on Continuous Integration with Xamarin.

How to exclude a .NET 5.0 project from build depending on the OS

We have a Visual Studio solution with several .NET 5.0 projects, one of which is a Windows Application (TargetFramework is net5.0-windows). It obviously fails to build on Linux and Mac. How can we make it so that it would build or not build, depending on the OS? The scenarios we need to support are:
Building from Visual Studio on Windows.
Building from JetBrains Rider on Windows and Mac.
Building from command line on Windows, Mac and Linux. For command line we currently use dotnet build, as well as dotnet test and dotnet pack which build the solution first.

Unable to build a freshly created Xamarin Cross-Platform project with MsBuild

Here the repro steps:
Start VS 2017
Create a cross-platform project ==> Sample.sln
Build it in VS ==> Ok
By building with it with the command "msbuild Sample.sln" I get 4 times the following error message: error MSB4066: The attribute "Version" in element "PackageReference" is unrecognized.
Anything missing in the .csproj files I am supposed to add?
Thanks in advance for your support.
Make sure that you use the path to msbuild.exe that is installed with Visual Studio. Use the Developer Command Prompt for Visual Studio 2017 if unsure, it has the PATH set up so that msbuild will point to the right executable.
This error happy when you use an old version of MSBuild (e.g. the version included in .NET Framework) that doesn't support the necessary features - metadata as attributes in this case.

Qt 5.8 msvc 2015 compile error

I have installed Qt using an offline installer qt-opensource-windows-x86-msvc2015_64-5.8.0. I have visual studio community edition 2017 installed with c++ build tools. because it's compiler was incompatible with the qt version, then I installed visual c++ build tools 2015 from http://landinghub.visualstudio.com/visual-cpp-build-tools . When I try to compile a project it gives an error :-1: error: LNK1158: cannot run 'rc.exe'. Heres how my qt kit looks like,
Can someone figure out whats the mistake and how to fix it.
Thanks.
I've fixed this both on my own machine and on several co-workers machines.
It tends to happen when you have both Visual Studio 2015 and VS 2017 installed. Or more precisely, multiple versions of the Windows SDK installed. When that happens, the vcvars32.bat script (located in your Visual Studio install dir) does not correctly add the location of the resource compiler (rc.exe) to your PATH. Thus, QT Creator runs vcvars32.bat (as specified in Qt Creator under Option->Build&Run->Compilers, but the tools directory for the Windows SDK Kit isn't properly added to the PATH environment.
The simple fix is to add the appropriate version of RC.exe to your path.
Do this from the command line:
cd "c:\program files(x86)"
dir /s rc.exe
You'll get several versions (x86 and x64) and for several versions of the SDK. Add the PATH for where rc.exe lives for the version that corresponds to the SDK and build flavor to your vcvars32.bat startup script.
For example:
PATH="C:\Program Files (x86)\Windows Kits\10\bin\10.0.15063.0\x86";%PATH%
Restart Qt Creator and that should fix it.
Another fix that worked for me is to uninstall all versions of Visual Studio (and all those side installs of SQL, Windows SDKs, dev tools, etc...). Reboot. Then cleanly install VS 2017 again. Then cleanly uninstall and re-install all of Qt again. That seemed to work for me. A wonderful way to spend an afternoon.
If you update to Qt 5.9 it supports MSVC 2017. However, if you want to get it working with 5.8, I believe you might be missing the Windows SDK. You can download the SDK from Microsoft for Windows 7, 8 or 10, just get whichever version is appropriate for you.
With some googling I found a couple of other somewhat related solutions here, & here, and I've summed them up below:
If you've already got the SDK or installed it and it still doesn't work, it appears that copying rc.exe and rcdll.dll from the WindowsSDK folder to your MSVS installs \VC\bin folder may fix the problem. You might also try copying those same two files to Qt's \Qt*version number**compiler version*\bin.

Qt 5.3 configuration error for VisualStudio 2010

I am relatively new to the Qt. At the moment I'm trying to configure Qt library for my machine before installing add-in for VisualStudio'10. I tried to download Qt library only (withouth a Qt creator IDE), and found "qt-everywhere-opensource-src-5.3.2.zip" and extracted it to my external drive: "F:\Programs\Qt\5.3.2". Then I run command "configure" on VisualStudio command prompt.
F:\Programs\VStudio'10\VC>cd F:\Programs\Qt\5.3.2
F:\Programs\Qt\5.3.2>configure
After a while it gave me following error:
Running configuration tests...
NMAKE : fatal error U1077: 'F:\Programs\VStudio'10\VC\BIN\link.EXE' : return cod
e '0x463'
Stop.
Could not find output file: No such file or directory
WARNING: The DirectX SDK could not be detected:
There is no Direct X SDK installed or the environment variable "DXSDK_DIR" is
not set.
Disabling the ANGLE backend.
WARNING: Using OpenGL ES 2.0 without ANGLE.
Specify -opengl desktop to use Open GL.
The build will most likely fail.
On the installation instruction that was found on Qt webpage, it was said to set environmental variables: "Add this 2 paths to the Environment Variables: “C:\Qt\2009.01\bin” and
“C:\Qt\2009.01\qt\bin”." But I was unable to find any "bin" directory in my qt-everywhere folder. Instead I set up following variable to my path: "F:\Programs\Qt\5.3.2\Qtbase\bin". Still no help.
How can I resolve these issues? Any ideas and help are highly appreciated.
What you've done is more like attempting to prepare building Qt itself from the source code (but that is not exactly how to do that, anyway). You don't need that at least now but when you start customize Qt framework, say, for static build. That is when configure tool comes handy. And you will need to read on that.
You need just to download its installer from: http://qt-project.org/downloads
I assume you don't have prebuilt Qt and Qt Creator in your system but that is prerequisite for what you want to do. Take either Community version or start download immediately. After you've installed certain Qt version for your platform including Qt Creator (which is native Qt IDE) you will also be able to install and use Visual Studio AddIn. And then take Visual Studio AddIn for Qt 5 from: http://download.qt-project.org/official_releases/vsaddin/qt-vs-addin-1.2.3-opensource.exe and install it. Read the instruction on how to use it. There will be some new menu for importing Qt project, though.
BTW, Qt Creator itself is not bad at all and maybe preferable for most of Qt development tasks except some debugging. I maintain entire project in Qt Creator and write the code there and only occasionally go to Visual Studio with AddIn installed to import Qt project there for some better debug experience.
you can try run "configure -opengl"
or , you can download Microsoft DirectX SDK and install it ,then try again.
http://www.microsoft.com/en-us/download/details.aspx?id=6812

Resources