I am using Visual Studio Community 2022, and I was wondering if you could use another CLI to run/debug a c# console application. (I can't use cmd.exe or powershell because it's blocked by the admins of the device I'm using). Git Bash would be preferred, because it's already installed. Thank you!
Edit: Looks like you can't do this. dotnet run just tries to open the blocked binary, no matter where you run it. I think the admins hate everyone though because they allow you to install lots of things (like Unity, vscode, etc.) but running anything just doesn't work.
Thanks for trying everyone!
use this to run your program in CLI but you cannot debug it if you want to debug use debugger mode of vs2022,
If it's a framework-dependent application (the default), you run it by dotnet yourapp.dll.
Run the project in the current directory:
dotnet run
check Microsoft Docs dotnet run for more options.
CLI: Use Vs2022 Terminal in View->Terminal it may help You to run it.
Related
So I have a solution on Windows that I want to compile so that it works on Mac. How do I do this without actually having a Mac?
Thanks for any help.
You'd better use Linux (or WSL) to run dotnet publish (as you'll need to call chmod to manipulate the execute permission). I have a sample PowerShell script here.
In short you need the following for your executable on .NET Core 3.1.
dotnet publish --self-contained -r osx-x64 -c release -o ..\output\darwin_x64 -p:PublishSingleFile=true
Set-Location output
Set-Location darwin_x64
chmod a+x executable
Compress-Archive * -DestinationPath ..\darwin_x64.zip
Set-Location ..
However, this approach only targets console applications. Applications with user interface require much more effort to port to Mac, and you need a Mac in most cases.
Set-Location ..
I see you are a new contributor. Welcome!
My understanding is that iOS or MacOS code needs to be build on a Mac and that this is non-negotiable per policy made by Apple. Here is a current link that describes how to pair your windows machine to a remote mac at which point the builds take place automatically.
You can even deploy over wireless. For example, the way I am set up, I build the project on my Windows machine which is paired over wireless to my MacBook Pro which deploys over wireless to my iPhone. Works great.
Another aspect of your question here is that while the logic of your app can be made portable by using NET Core for the code behind or better yet NET Standard, the sticking point is often that UI code is wildly platform specific.
Without expressing an opinion of whether it's a good thing or a bad thing, one approach that is supported in the Visual Studio 2019 Community free edition is Xamarin mobile cross platform development. (Can be included in your project with Xamarin.Forms and Xamarin.Essentials nuGet packages.) This way you can create UIs only one time using xaml that will work across devices.
I've used Xamarin for a number of years, and in my experience it's performing well for the Android/iOS/UWP apps that I've ported. I believe that Xamarin for MacOS is also online now but I haven't used it.
Your question is a good one, but pretty gigantic in scope. I hope this info will at least get you started in a direction!
As far as I know you can just code for .NET core, but compilation must be done in a Mac
We are going to release an application developed using C# and now recently we faced a problem building set up application using Advanced Installer 15.6.
To put it in more detail we are going to one to install .NET Framework 4.6.1 in silent mode (with no window).
We tried to find the solution for several hours and also asked Advanced Installer team, but haven't find or receive any answer.
Tried as followings.
/q
/quiet
...
Hope to receive quick answers.
Do you launch the setup package elevated, for instance by using Run as admin , or as a child process within an elevated process? If the setup package is not launched elevated the prerequisite installer will fail to install silently from what I know.
Basically, my school only has Mac computers, however they're telling me to learn C# and to do so using Visual Studio. However, the school program is fairly new and the projects are self-guided. I've been coding in C# using Visual Studio and it's been working so far - it's run successfully and everything. However, I can't seem to find a way to export or publish my code into a standalone application. I've tried using WineBottler to convert the .exe into a .dmg, but I can't seem to make it work.
How should I do this? Moving to Windows or another IDE/compiler isn't an option. I've currently been creating my projects in a Console App, but I could change that if necessary.
After quite a bit of experimentation and research, I've found that while you can publish a .NET Core Console App within Visual Studio for Mac, the feature is not supported within the GUI of the program (for whatever reason).
In order to publish, you have to Control-Click on the solution in the Solution Explorer and open the project in the command line by clicking Tools > Open In Terminal.
Once there, type in the command:
dotnet publish -c Release --framework netcoreapp2.1 --runtime osx-x64
This will create a self-contained program for 64-bit mac os on the v2.1 .NET Core framework. The runtime can be changed for different operating systems and the version number for netcoreapp can be changed based on which version you're using and what is compatible with any plugins for your program.
The final product will be found in yourprojectfolder/yourprojectname/bin/Release/netcoreapp2.1/osx-x64/publish
You should have no issues creating and compiling .NET CORE console apps using a Mac. These apps will have limited .NET functionality, do not have .exe files, and are platform agnostic. Here is a quick guide you can reference to decide if .NET CORE is the right option for you.
If you are trying to create WinForm apps or something similar, you cannot do this on a Mac. There are "work arounds" using Wine or other tools, but my experience with those options has been suboptimal at best. If you need to create apps like this, then your best option is to program on a Windows machine. Perhaps ask your school to enable bootcamp and install Windows 10 OS on one of the Mac machines.
You can generate exe using the terminal if you are on OSX. You can follow this post
It requires :
Visual Studio For Mac
A .cs file
Few lines in terminal
First of all, im not sure if there is a specific forum thats more suitable for request about Jenkins, but I figured I just post it here.
So, I have this C# project, it right now requires Visual Studio 2015 to build and I would like to automate builds with Jenkins. This is the first time I'm using Jenkins and I was able to set it all up, it fetches the code from the gitlab repository, but right now there is no build action configured. For "fun" i tried to simply make it use a "windows batchfile" as build file and added echo test. Checking the console output it downloads the repository code and then tries to execute the batchfile, result is:
java.io.IOException: Cannot run program "cmd" (in directory "/var/lib/jenkins/workspace/Project"): java.io.IOException: error=2, No such file or directory
This of course makes sense, but I wonder now, is there a way to build a C# project with jenkins on a debian server without resorting to mono or something? I know that people build C++ projects for windows with Jenkins on a linux root, so there has to be some sort of cross compiling possibilities.
If the Visual Studio 2015 is a dealbreaker I can also strap it down to VS13 or even below. Any help is greatly appreciated!
/EDIT
Its probably important to say that Mono is NOT an option. Im using features like WPF that are not available for Mono.
Use Jenkins' MSBuild plugin.
Jenkins.NET is a good blog about using Jenkins in a .NET environment. First post is here.
Scenario
I have a server, that has NO Visual Studio Installed. It literally has a normal command prompt and nothing installed yet. We don't want to install anything (except the .Net framework which we have already done). We just want to install a bunch of C# Windows Services that we have written.
So far
I have been installing and running the windows service on my local machine using a "setup and deploy" project that I built into the application, which I could then use to install the service locally.
Question
How can I install the service on the server?
I imagine it can be done from the command prompt only, but what else do I need? - If anything? and where do I put the files that I want to install BEFORE I install them?
I imagine I will have to compile the application on my local machine in Visual Studio, then copy it over to the server, and then run an install utility to install it on the server?
Any help would be greatly appreciated.
according to this thread you need to run
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe
(replace c:\windows with your windows path)
Your server has a sc.exe (service control) command which allows you to install, uninstall, start, stop and configure services - no Visual Studio bits needed.
Run sc.exe -? at a command prompt to get a listing of all available options
I add code similar to the one in this article to my services:
http://www.codeproject.com/KB/dotnet/WinSvcSelfInstaller.aspx
Then I can install/uninstall them just by typing ServiceName -i or ServiceName -u at the command prompt. Makes it easier if it'll be installed by people who don't know .Net.