Mac Application from Gtk in Visual Studio Mac - c#

Im very new in Mac development environment. I installed Visual Studio for Mac, and created a new solution .NET/Gtk 2.0 project to build a GUI file rename tool. I created the tool. However when I build it in debug and release, it generates .exe file which I can only run with the shell.
However, I need to build this program in app bundle so that I can send it over to other users and they can run it by clicking on it. Is there any way to accomplish this?(I have spent a few hours on this but couldn't see a clear document that explain to me. If nothing works then I need to rewrite it in Java).
Thank you so much in advance!

Assuming Mono is installed on all of your target machines then you can put together (manually) a .app package folder that will run your .exe file when a user double-clicks on it. There's a certain set of things you'll need to put in the .app package, one of which is a command shell file that will kick-off your .exe and will be executed when the .app is run.
B.t.w. Visual Studio Mac and Xamarin Studio and MonoDevelop are all basically different twists on the same thing, MonoDevelop. VS mac and XS have extras but the basic underlying IDE is MD. Whichever of these products you use to compile your code is unlikely to churn out anything different to the next.
The structure of the basic .app folder:
MyApp.app
+-- Contents
--- Info.plist
+-- MacOS
--- MyApp
--- MyApp.exe
+-- Resources
--- MyApp.icns
The contents are as follows:
Info.plist is a Mac OS specific XML file that contains a description of your .app package. It will look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>MyApp</string>
<key>CFBundleIconFile</key>
<string>MyApp.icns</string>
<key>CFBundleIdentifier</key>
<string>com.myapp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>My App Name</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<key>CFBundleSignature</key>
<string>xmmd</string>
<key>CFBundleVersion</key>
<string>1.2.3</string>
<key>NSAppleScriptEnabled</key>
<string>NO</string>
</dict>
</plist>
The MyApp.icns file is an icon file you want to use as the icon for your app package.
The MyApp.exe file is your compiled .NET exe.
The MyApp file is an executable command file that is executed when the .app package is executed by the user. This is referenced in the plist file under CFBundleExecutable and has to be executable (+x permissions, ). This is what it might look like:
#!/bin/sh
DIR=$(cd "$(dirname "$0")"; pwd)
MONO_FRAMEWORK_PATH=/Library/Frameworks/Mono.framework/Versions/Current
export DYLD_FALLBACK_LIBRARY_PATH="$DIR:$MONO_FRAMEWORK_PATH/lib:/lib:/usr/lib"
export PATH="$MONO_FRAMEWORK_PATH/bin:$PATH"
exec mono "$DIR/MyApp.exe"
Hope this helps. Cheers, Martin.

Related

You don't have an extension for debugging C#, Should we find a C# extension in the Marketplace?

I'm trying to debug a C# script using VSCode. but when I hit F5 it shows
But I do have the C# extension installed in VSCode
About my VSCode
Version: 1.56.2 (system setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19042
I also have Dotnet installed on my machine
dotnet --version
5.0.203
Previously, VSCode used to resolve all the necessary dependencies and create the necessary files for debugging a C# script. Maybe the latest update has some issues?
If you have issues with that I suggest going to 'view' and then press command pallet or press Ctrl+Shift+P and then search 'generate assets for build and debug' and if you want it to open up a new window and execute your code instead of it running in the terminal:
Go open .vscode
Then select launch.json and then go to where it says console and write this instead:
"console": "externalTerminal",
Is there a .vscode folder in the folder you are working out of or in a parent folder? Not having that will cause issues with VS-Code loading extensions.
Did you open VS-code by clicking on a source code file in File Explorer? If so then VS-Code is currently unaware of your .vscode folder for that project.
Either way the solution is to open the folder through VS-Code by going to File->Open Folder and select the folder your project is in. In the former case you will also get a message asking you if you want to generate something and you need to click yes on that. This also seems to solve some instances of getting the 'Unable to generate assets' and 'Omnisharp server is not running' errors.

Unity, Xcode, Compatibility List?

Problem: I am unable build and Run from Unity editor, or attach Monodevelop to a device process.
Specific Versions:
Unity5.2.2f
Xcode 7.1 (7B91b)
I believe this all has to do with compatibility as Unity will spit out the small warning, when you Build and Run from the editor:
Unity xcode plugin has not current Xcode in its compatibility list.
Please launch the project manually
UnityEditor.HostView:OnGUI()
Where can I find said "Xcode compatibility list"?
Workaround for whenever in the future this might happen again:
Open Applications in Finder
right-click XCode app > Show package contents
open Contents
open Info.plist
copy the DVTPluginCompatibilityUUID string
In the Finder window, press ⇧⌘G (Shift+cmd+G)
Enter /Applications/Unity/PlaybackEngines/iOSSupport/Tools/OSX/Unity4XC.xcplugin/Contents
open Info.plist in your favorite text editor
find the part with:
<key\>DVTPlugInCompatibilityUUIDs</key>
<array>
<string>63FC1C47-140D-42B0-BB4D-A10B2D225574</string>
<string>37B30044-3B14-46BA-ABAA-F01000C27B63</string>
<string> etc...
add a line with:
<string>[Paste the copied UUID here]</string>
before this line: </array>
Save the file, and provide your password to overwrite the plist.
You'll be able to have Unity run the build process in XCode again (after restarting XCode)

How do I mimic the build and deploy functionality in the AWS Toolkit for Visual Studio via a script?

I have a .NET solution with several different projects. Each of them I have now set up via the AWS Toolkit so I can just right click and hit "Redeploy to AWS..." but what I would like to do create a script (PowerShell maybe?) that builds and deploys all of my projects automatically.
I know there is a CLI version of the AWS Toolkit called awsdeploy.exe but it doesn't seem like that will perform the compilation and archiving of a project like the AWS Toolkit plugin does.
How do I mimic this behavior?
So I'm currently tackling this question at work, with partial success. What I have found is that you can do the packaging with msbuild, and then deploy with awsdeploy.
For example, if I have a visual studio solution call bas, with two projects, foo and bar, and I want to deploy bar, then I first package bar with msbuild.
msbuild bar/bar.csproj /t:Package /p:PackageLocation=barPackage.zip
This should create a package call barPackage.zip under the bar directory. If you don't find it, look at the msbuild output as it should let you know where it was created.
Now that we have the package, we can deploy. Awsdeploy needs a configuration file. It's just a file that contains key value pairs of the form "key = value". There is an example file in a directory called Samples\, in the same directory where the awsdeploy.exe is located.
If you are using visual studio there is an option for creating the config file while deploying to aws.
More info: http://docs.aws.amazon.com/AWSToolkitVS/latest/UserGuide/tkv-deployment-tool.html#deployment-tool-configuration-file-format
Let's assume we have a configuration file called deployConfig.txt then we can call awsdeploy like so
awsdeploy /r deployConfig.txt
Note that the /r is for redeploy. This assumes that you already have an environment running.
If you don't want to put credential inside the file, you can also do.
awsdeploy /r /DAWSAccessKey=stuff /DAWSSecretKey=stuff deployCon
In general anything we don't want on the file we can specify on the command like by adding /Dsomething=stuff. As you can see above to specify AWSSecretKey we do /DAWSSecretKey=stuff.
The visual studio generated file does not list the location of the package so what I've been doing is
awsdeploy /r /DAWSAccessKey=stuff /DAWSSecretKey=stuff /DDeploymentPackage=bar/bar.zip deployConfig.txt
This almost works for me. But sadly it doesn't quite do the trick. It deploys the package, and I can see the environment trying to load it but fails at some point. I don't know why it's failing to load it. It loads it fine when I deploy it from visual studio.
This is how we're handling it. All of this runs on our CI server:
Step 1 - build web deploy package with msbuild:
msbuild website.csproj /t:WebPublish /p:WebPublishMethod=Package
/p:DesktopBuildPackageLocation=website.zip /p:Configuration=Release
/p:DeployIisAppPath="Default Web Site"
Step 2 - deploy with awsdeploy:
awsdeploy.exe /DAWSAccessKey=**** /DAWSSecretKey=**** /r config.txt
config.txt:
DeploymentPackage = .\website.zip
AWSProfileName = ******
Region = us-east-1
Template = ElasticBeanstalk
UploadBucket = ***********
Application.Name = ***********
Environment.Name = ***********

A referenced project's pdb file not in this projects application files list

I have a C# WPF solution that contains three projects, MyApp, MyAppAdmin and MyAppLibrary. MyAppLibrary is referenced by the other two.
I need to be able to include MyAppLibrary.pdb when I publish MyApp (click once) but it does not show up in the projects Application Files even with "Show all files" checked.
If I open the Application Files for MyAppAdmin and have Show all files checked MyAppLibrary.pdb is in the list.
Any idea as to why the difference and/or how I can get it into the list for MyApp?
Thanks,
Dave
You didn't say what type of projects you have, so I can't confirm that this will work for you. If you have a web project, then you should be able to uncheck the Exclude generated debug symbols option on the Publish Web property page in Visual Studio.
Failing that, you can try to set that value directly in the project file. Right click your project file in a Windows Explorer window and edit in a text editor. You can add a new PropertyGroup with this value to the end of the file (within the Project element) like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup>
<ExcludeGeneratedDebugSymbol>False</ExcludeGeneratedDebugSymbol>
<PropertyGroup>
</Project>
It looks like this issue is related to what solution platform is used. We need to run the application in 32 bit mode due to some dependancies we have. When this was originally setup we created a custom solution platform for some reason where MyAppLibrary and MyAppAdmin used the Any CPU platform but MyApp used x86. I switced to using the Any CPU for all of them and then specifying in each project to target the x86 platform.
Once this was done I know can see and include MyLibrary.pdb in the published output.
Dave

Merge msi and exe

My deployment project creates and .msi-file and an .exe-file. Is it possible to merge these into one .exe?
Yes, you can create a self-extracting installer containing both MSI and the setup.exe bootstrapper file.
I think it is possible to do that with WinZip, or you can use IExpress coming with Windows. Here is a guide how to create a self-extracting executable with IExpress. You can either use the IExpress wizard or manually write a config file which you then can execute in the post-built step of your setup project, e.g. by calling
IExpress /N /Q MySetup.sed
A sample configuration file would look like this:
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=1
HideExtractAnimation=1
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
TargetName=MySetup.exe
FriendlyName=My cool application
AppLaunched=CMD /C setup.exe
PostInstallCmd=
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="setup.exe"
FILE1="MySetup.msi"
[SourceFiles]
SourceFiles0=
[SourceFiles0]
%FILE0%=
%FILE1%=
There is a little caveat however with the self-extracting installer scenarios. Due to another fix these scenarios are broken with the bootstrapper (setup.exe) created by VS2008 SP1. For a workaround see the following thread: http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/3731985c-d9cc-4403-ab7d-992a0971f686/?ffpr=0.
I like it, you can see how to use IExpress on this link!
The only problem I see was that I've generated a installer on Windows Vista 64bits, I was trying to install the generated .exe in a server with Windows Server 2008 32bits, but it throws an error about processor type.
Another option could be 7zip with sfx plugin: http://www.7-zip.org/download.html or WinZip self extractor: http://www.winzip.com/prodpagese.htm

Categories

Resources