How can I run a visual studio project from the mac command line? - visual-studio-mac

I have a visual studio project that generates an exe file. I can run this project from within Visual Studio Community for Mac simply by clicking Run for the Release or Debug configurations.
I need to be able to do this from the command line. I've tried using wine but it throws exceptions that I never see in VSC.

Thanks #Lex Li!
The solution is to open a terminal and run
mono <path to your app> <your app's arguments>

Related

CMake - could not find any instance of Visual Studio [duplicate]

When I am trying to install CMake I get the error:
Visual Studio 15 2017 could not find any instance of Visual Studio.
I am using Windows 7 and Visual Studio 2017. The CMakeOutput.log file writes:
The system is: Windows - 6.1.7601 - AMD64
Any ideas?
I ran into the same error and performed the following steps to resolve the issue:
Open Visual Studio
Go to Tools -> Get Tools and Features
In the "Workloads" tab enable "Desktop development with C++"
Click Modify at the bottom right
These steps resulted in the "Visual C++ tools for CMake" feature being installed, but the other optional C++ features included in this workload may also helpful for what you are trying to do.
After the Visual Studio updater finishes installing try re-running the command. You may need to open a new command window.
In my case, I installed Visual Studio, selecting the workloads and modules that I wanted, but I ignored the request to reboot, assuming that shutting down the computer at the end of the day and restarting it the following day would suffice. I was wrong.
The following day I tried a cmake build and got the "could not find any instance of Visual Studio" error. After several attempts to resolve, I re-ran the installer, made no changes to the configuration, and clicked Modify. This time I let it reboot the computer. The reboot took a long time. After which my cmake build worked.
If you have already installed the workload Desktop development with C++ and still getting the following errors while using visual studio 2022 for flutter
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
Building Windows application...
Exception: Unable to generate build files"
Solution: Follow these steps,
Edit your_flutter_path\packages\flutter_tools\lib\src\windows\build_windows.dart, and change the constant on line 28 from Visual Studio 16 2019 to Visual Studio 17 2022
Delete flutter_tools.stamp and flutter_tools.snapshot from your_flutter_path\bin\cache\
Run flutter clean in the project
I had the same issue "could not find any instance of Visual Studio"
but with Visual Studio 2019 (Community Edition) and I just had to configure the VS160COMNTOOLS variable so that CMake correctly detects Visual Studio.
export VS160COMNTOOLS="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools"
(cf https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html)
With Visual Studio 15 2017, the variable you need should be VS150COMNTOOLS.
(cf https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2015%202017.html)
NB: in my case, in a Travis-CI workflow, I installed Visual Studio using the commands (no need to reboot):
choco install visualstudio2019community
choco install visualstudio2019-workload-nativedesktop # required
With only the first package, CMake detection of VS2019 failed.
I was configuring a Jenkins build node and could successfully run CMake GUI manually but command line use or builds using the CMake plugin would fail with:
Visual Studio 16 2019 could not find instance of Visual Studio.
-A x64 parameter was added with no change in result.
The problem was that CMake could not determine the Windows SDK version.
By adding CMAKE_SYSTEM_VERSION parameter CMake was then able to find Visual Studio.
-D CMAKE_SYSTEM_VERSION=10.0.18362.0 (use your windows SDK version)
Environment:
windows 10 system build: 19042
CMAKE 3.19.4
VS 2019 Professional 16.8.4
Jenkins 2.235.1
Full command line that worked:
"C:\Program Files\CMake\bin\cmake" -G "Visual Studio 16 2019" -D CMAKE_BUILD_TYPE=Release -A x64 -D CMAKE_SYSTEM_VERSION=10.0.18362.0
When using VS 2017, be aware that this is really VS 2015, and CMake identified it as VS 2017 2022 which is not the version of VS 2017 I had, that gave me this error. So the conclusion I offer is to try different versions, specifically the 2015 one.
I had a similar issue where installing libzmq in my npm project was throwing the same error and that wasn't getting solved by enabling "msbuild" under "Desktop development with C++" in the Visual Studio installer.
My solution ended up being to reinstall the Windows build tools for npm with the following command.
npm install --global windows-build-tools
Note: Remember to run the command prompt (or whatever terminal you are using) as admin before running this.
If the CMake used to work with the installed Visual Studio and is broken someday, then the problem could be VS requires system reboot to complete some update.
For quick verification, rename HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\Setup\Reboot to like HKLM\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\Setup\Reboot.bak, then re-run cmake which should succeed. Don't forget to rename the registry back and reboot the system if this is the problem.
In my case, I was selecting different version of visual studio in that configuration dialog box whereas I installed different version.
Do select the same version.
Above solutions did not solve this issue for me. After installing node.js from https://nodejs.org/en/download/ apparently a correct version of windows-build-tools was installed
I reinstalled the Visual Studio 2019(my former one is 2017 version ) with all those settings required(my cmake version is 3.23.0),and it works. So try to install different versions.
In my case, the problem was gone after I deleted the previous cmake result directory and then ran cmake again.
if you have installed two or more Windows 10 SDK, delete them excluding latest one.
Try downloading the windows-build-tools package.
npm install --global --production windows-build-tools --vs2015
This step should be the end-all-be-all solution to fixing node-gyp problems. For most people, that’s true. NPM has a package called windows-build-tools that should automatically install everything you need to get node-gyp working, including the Microsoft build tools, compilers, Python, and everything else required to build native Node modules on Windows.

Running vs2017 DevEnv from command line with VS2017 Installer Projects

I have inherited a bunch of VS2010 (argh!) installer projects (.vdproj) that install some Win Services
Ofcourse in VS2017 those don't exist anymore but the extension 'VS2017 Installer Projects' works great. I can just open them fine and build, which produces the msi files.
However this needs to be done on the Jenkins machine (running Windows 7) as well. So I installed VS2017 on the Jenkins machine with the Project Installer extension and tried to first run the project from the IDE. Works great. Produces the .msi without problem.
Then I tried to run it from a command line:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe"
D:\ServiceInstaller\xxxServiceInstaller.vdproj /build
And it does NOT produce anything. Am I trying to do something that is not possible?
There are all kinds of long term solutions of course such as TopShelf, AdvancedInstaller, WIX etc with nice Jenkins plugins but for now it would be nice if I could make this work.
I've made following batch file to call with solution file parameter:
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild\DisableOutOfProcBuild.exe"
devenv /rebuild "Release|Win32" %1
Also make sure that in Visual Studio Configuration Manager Setup build is enabled.

Visual Studio for mac: how to run a terminal

I'm new to Visual Studio on mac, can someone show where we can run a terminal window to execute some git commands?
Terminal window is not a part of the built-in tools within Visual Studio for Mac. There might be some add-ins or extension for this, but I am not aware.
However, there is a GUI Git tool called 'Version Control' which is integrated to VS, you can use it.
If you still want to use a terminal window, you can open a separate terminal window, outside of the VS. Alternatively there is an VS fro Mac add-in that allows you to open a terminal window (again outside of the VS) on any solution's dir.
UPDATE:
You can open any directory from Visual Studio for Mac in a terminal by right-clicking any project directory > Tools > Open in Terminal
In Mac VS2019, I found access to Terminal
under Solution navigation
Select your Project
Crl-Click (hold)
Navigate to Tool
Open in Terminal
It seems to work for me!
Visual Studion for Mac Previews now include a terminal as of April 2020
Tools->Show Terminal Window or crtl+`
https://devblogs.microsoft.com/visualstudio/meet-visual-studio-for-macs-new-integrated-terminal/#:~:text=%20Meet%20Visual%20Studio%20for%20Mac%E2%80%99s%20New%20Integrated,at%20any%20time.%20%20...%20%20More%20

mdtool creates IPA file when using release but not when using debug configuration

I want to create an IPA file for both the release and debug for my app created in xamarin. I created the release IPA file with the following command in Bamboo:
-v build -t:Build "-c:Release|iPhone" CustomerApp.sln
This can be replicated on the terminal too by doing this:
/path-to-/mdtool -v build -t:Build "-c:Release|iPhone" CustomerApp.sln
But when I try to use the "-c:Debug|iPhone" this will not create the ipa file, when trying to use the terminal or Bamboo. I then tried different configurations like "-c:Release|iPhoneSimulator", "-c:Debug|iPhoneSimulator", "-c:Ad Hoc|iPhone" and "-c:Debug|iPhoneSimulator" but all of these will not create the IPA file. Why is this?
I know that the path to mdtool and the solution are fine because it works for the Release IPA but is it to do with the configuration in either Xamarin or Xcode?
If you are on the same Mac as the one you are running Xamarin Studio, it should mimic the provisioning profile setup you have in the IDE. If the build in Xamarin Studio builds with that combination with no drop down change on the main project, I would expect the mdtool to work. Note that now in Visual Studio 2017 for Mac it will be vstool under the /Applications/Visual Studio.app folder.
My build line looks like this:
/Applications/Visual\ Studio.app/Contents/MacOS/vstool --verbose build --f --target:Build --configuration:"Debug|iPhone" --buildfile:my.sln > $BuildResults
Update January 2019, I have found very little guidance on the web about what exactly vstool can do and how to use it. I believe it to be the Microsoft version of the mdtool, which is part of the Monodevelop project at Github (mono/monodevelop). The mdtool source code is under monodevelop/main/src/tools folder. It appears to be a runner for a variety of tools available in the Monodevelop / Visual Studio installation. Running
/Applications/Visual\ Studio.app/Contents/MacOS/vstool -q
will list out the available tools. There is also a man page as part of the Monodevelop build process, at monodevelop/main/man which provides a bit more enlightenment. I was shown how to use the specific command by someone who was very familiar with the project.

How can I compile a Delphi application without using the IDE?

I need to build the components, package, and project file without using the Delphi XE7 RAD Studio IDE. Is there some way to do this using command line instead?
When you installed RAD Studio, it added a shortcut in the start menu named RAD Studio Command Prompt. Execute that shortcut. You now have a command prompt window for an environment that includes all you need to build at the comment line.
Change directory to the directory containing your .dproj files.
Execute the following command: msbuild YourProjectName.dproj.
If you have multiple projects build them all. Of course you'd want to script all this up in due course.
Control the build target (clean, make, build) and configuration (debug, release, win32, win64) using command line arguments as documented here: http://docwiki.embarcadero.com/RADStudio/en/Building_a_Project_Using_an_MSBuild_Command
For more details, start with the documentation here: http://docwiki.embarcadero.com/RADStudio/en/MSBuild_Overview

Resources