Also, since my native machine is a Mac and.NET Core runs on a Mac and there is now Visual Studio for Mac Preview this is a great time to try to get a.NET app using the Angular CLI up and running. Visual Studio Code command line options (switches). Opening Files and Folders. Sometimes you will want to open or create a file.
Answers
- USMember, Forum Administrator, Xamarin Team, UniversityXamurai@JeremyGannaway.9065 said:
Is there a way to see/log the build commands that Visual Studio for Mac uses to build Xamarin.iOS and Xamarin.Android projects?Visual Studio for Mac does not emit a command line command to launch the build, it invokes MSbuild by other means (Target/Tasks?), so there is no command line for you to copy.Perhaps if you share the command you are using in Jenkins, we may be able to spot an issue. - I think I discovered the configuration issue I had, which by the way @JGoldberger, I found your demystifying-build-configurations blog article very helpful as I've been working on my build configurations the past few days.However, I'm still running into the issue of a Release build not being able to be installed on the Simulator. Here are the steps I'm taking:
- Choose
Release|iPhoneSimulator
as myConfiguration|Platform
- Right-Click the iOS project, choose Build
- After the build, I get a .app file in my /bin/iPhoneSimulator/Release folder. If I drag the file over to the Simulator, I get a message that says 'This app couldn't be installed at this time'.
- Click on the 'Play' button in Visual Studio for Mac to deploy to the Simulator.
- Click the 'Stop' button and uninstall the app from the Simulator.
- Now, I can drag the .app file to the Simulator and it will install just fine.
Something interesting happens between step 3 and 4. The .app file increases in size by ~10 MB. From what I'm seeing, 2 files are being added to my .app file:- Xamarin.iOS.dll
- an 8MB extensionless file that matches the name of my app
Does anyone know the specifics of what is going on? For Debug builds, the .app files that are generated from a Right-Click/Build are ready to be installed on the simulator (.app files are found in /bin/iPhoneSimulator/Debug/device-builds) - Choose
- The issue I encountered with the simulator build was related to the 'Supported Architectures' setting. By default,
Release|iPhoneSimulator
has 'Supported Architectures' set toi386 + x86_64
. The following command produced a .app file that could be installed on the simulator with no issues:msbuild {path-to-your-solution}.sln /p:Configuration=Release /p:Platform=iPhoneSimulator /p:Codesignkey={your-code-sign-key} /p:CodesignProvision={your-code-sign-provision} /p:MtouchArch=x86_64
- USMember, Forum Administrator, Xamarin Team, UniversityXamuraiSo it seems you got this sorted out. Glad to hear it!
- Hi guys am kinda new to cross platform app development with VS for mac but am also having similar issues when i use this build command 'MSBuild Path/to/my/ios.csproj' i noticed that the 'device-build' folder in the bin section of my ios project doesn't get createdbut when i do it via VS for mac IDE which is by right clicking on it and selecting build project it gets created any ideas what am doing wrong here please.the reason am trying to get it to work from command line is i have a jenkins job which is connected to a git repo so i want to always pull down the latest app code build it and run my automated tests against on it.Thanks
Some of my other articles about Visual Studio Code :
Grab the Bits
Install Visual Studio Code and ASP.NET 5 for OSX. The Visual Studio installer is straight-forward, but make sure you read the release notes on how to install ASP.NET 5 on a Mac.
Once everything installed, run this command:
You will see the following options :
Select a “Console Application” using your up and down arrow keys and give it a name. It will scaffold the project for you.
Notice that it is asking you to run a couple of commands :
The last command dnx . run is for Console Applications only.
If we list out the files contained in our Console application before running the restore command, then we’ll only see two files and one is hidden:
- Program.cs
- project.json
- .gitignore (hidden)
Change into the directory that has your console app and run the dnu restore command and you now have a project.lock.json file.
Run the dnu build command and you see several error messages.
Note: You can safely ignore these for this release.
Type dnx . run and the Program.cs file will display “Hello World” in the terminal.
Switch over to Visual Studio Code
Navigate to your Console Project and open it in Visual Studio Code or you can simply type “code .” if your already inside the directory that you want opened.
![Visual studio for mac command line build Visual studio for mac command line build](https://code.visualstudio.com/assets/docs/editor/command-line/hero.png)
You can run the app by pressing CMD-Shift-P and selecting “Run”. This will open a terminal window that displays “Hello World”.
Digging Deeper
We actually want to build and debug our app, so switch over to Program.cs and press CMD-Shift-B to build our app and you will be asked to configure the Task Runner. Copy and Paste the following text into the file that it opens. (called tasks.json)
This tells the editor to use xbuild instead of msbuild, since we are on a Mac.
If you switch back to Program.cs and hit Control-Shift-B again, then nothing will happen.
Select a line that you wish to debug(1) and press the “Debug Icon”(2) and finally hit the “Play button” (3).
You’ll see a message that asks you to setup the launch configuration for your app.
Switch back over to the files view and you will see a launch.json. Replace the contents with the following:
Now we’ve declared this as a mono project and gave it a program name to the executable. If we try to debug the application now, it will say :
Taking a look at the output window, we will see :
We are Missing the .csproj file!
We simply need to create a file and call it ConsoleApplication.csproj. I opened a ConsoleProject with Visual Studio and used the following code:
Now press CMD-Shift-B to build your project. You will see the following files have been created.
Put a break point on the Console.ReadLine() Method and try debugging the application again. You will now be able to “Step Over”, “Step In”, “Step Out”, “Continue” and “Stop” your console application.
You will also have a terminal window appear that shows the output so far :
Tweak the boilerplate code if you want to examine how the debugger validates what type a var is, etc. I also thought it was interesting that I could make my Mac beep with the Console.Beep() command even though the compiler says that it is not available in dnxcore50.
Like this Post?
As always, thanks for reading and smash one of those share buttons to give this post some love if you found it helpful. Also, feel free to leave a comment below.