Live reload and asp.net vNext on OSX - macos

How do you get the command "k kestrel" to live-reload (one of the advantage of asp.net vNext) on MacOSX?
Following "k -h", it looks like the command is "k --watch kestrel", however, it do not reload when I make a change into my sample HelloMvc Controller.

At the moment, according to David Fowler, there is a bug in Mono that prohibits detecting file changes. However, a new FileSystemWatcher was supposed to be merged recently so this might work soon!

I have managed to fix this problem by following the suggested solution posted by miguellira on this issue: https://github.com/aspnet/Home/issues/508
I skipped the first the the second steps, I simply changed my ~/.bash_profile by adding the following:
alias dnu="brew switch mono 4.1.0 && dnu"
code () {
brew switch mono 4.0.1
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
[[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
open -a "Visual Studio Code" --args "$F"
fi
}
export MONO_MANAGED_WATCHER=enabled
Regarding the bash_profile, if you don't know how to change it (or create it in case you don't have it yet) have a look on this link: https://discussions.apple.com/message/19065947#19065947

Related

How do I use FSI for F# 4 in my visual studio code?

The terminal in my Visual Studio keeps saying
F# Interactive for F# 3.1 (Open Source Edition)
How do I tell visual studio to use FSI for F# 4 ?
PS: Visual studio code and all extensions are already updated.
PPS: I am using mac
The Terminal within VSC is using your default shell, and thus will pickup the same path and thus fsharpi will be the same as if you ran it via Terminal.app or iTerm2.app.
If you have latest Mono version installed, it will place a fsharpi shell script in:
>which fsharpi
/usr/local/bin/fsharpi
Which in turn uses mono to execute in the fsi.exe CIL-assembly from:
/Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/4.5
Mono version 4.6.0 currently installs F# Interactive for F# 4.1
Grab the latest OS-X Mono version here.
Run:
cat `which fsharpi`
Mine returns:
#!/bin/sh
EXEC="exec "
if test x"$1" = x--debug; then
DEBUG=--debug
shift
fi
if test x"$1" = x--gdb; then
shift
EXEC="gdb --eval-command=run --args "
fi
if test x"$1" = x--valgrind; then
shift
EXEC="valgrind $VALGRIND_OPTIONS"
fi
# Beware this line must match the regular expression " (\/.*)\/fsi\.exe" when fsi.exe is fsi.exe.
# That's because the FSharp MonoDevelop addin looks inside the text of this script to determine the installation
# location of the default FSharp install in order to find the FSharp compiler binaries (see
# fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerLocationUtils.fs). That's a pretty unfortunate
# way of finding those binaries. And really should be changed.
$EXEC /Library/Frameworks/Mono.framework/Versions/4.6.0/bin/mono $DEBUG $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.6.0/lib/mono/4.5/fsi.exe --exename:$(basename "$0") "$#"

Delete App on Simulator through Command Line

Im writing an automated test that will use the Instruments automator to run a series of UX tests on my application. The problem is, I need the app to run on a fresh install for the specific set of tests that I am running. Is there a way to delete an app in the simulator through the command line?
Specifically, I am looking for something like this:
xcodeBuild -delete myApp.app
Something like this might work, although I haven't fully tested it:
rm -rf ~/Library/Application\ Support/iPhone\ Simulator/6.0/Applications/*
Substitute the proper simulator version number for the 6.0 of course.
I actually ended up using the solution found here: https://stackoverflow.com/a/5128616/608739
The apple script works great and gets around all those pesky simulator issues.
--------------- OLD POST -------------------
Using jpancoast's lead, I modified his script to find and clear the latest version of the app on simulator:
CURRENT_SDK=""
if [ -z "$RUN_ON_SPECIFIC_DEVICE_OPTION" ] ; then
CURRENT_SDK=$(xcodebuild -showsdks | grep 'iphoneos[0-9].[0-9]' | grep -o '[0-9].[0-9]' | head -n1)
else
CURRENT_SDK=$(xcodebuild -showsdks | grep 'iphonesimulator[0-9].[0-9]' | grep -o '[0-9].[0-9]' | head -n1)
fi
rm -rf ~/Library/Application\ Support/iPhone\ Simulator/"$CURRENT_SDK"/Applications/*
The script checks to see if we are currently running on device or not. It then finds the folder corresponding to the latest SDK (assuming your project is building on that SDK) and deletes all applications associated with that SDK version. Further refinement can be made to only delete specific apps you are interested in.
Assuming you know the iOS version and the name of the app, this is a script I put together to remove a single app. It comes in handy if you don't want to reset the entire simulator and lose all other installed apps.
The script below is part of a larger script I use, but should work as shown. I've got this saved as simulator-uninstall.sh, you can then uninstall an app using something like:
./simulator-uninstall.sh ios=7.1 app="My App"
Here's the script (note, bash is not my strong point, but this worked for me!):
#!/bin/bash
for p in "$#"; do
# Parse out each param which needs to be of the form key=value
# Then remove any quotes around the value, because we will quote all vars anyway
IFS="=" read argkey argvalue <<< "$p"
argvalue="${argvalue%\"}"
argvalue="${argvalue#\"}"
case $argkey in
ios) IOS_VERSION=$argvalue
;;
app) APP_NAME=$argvalue
;;
esac
done
SIMULATOR_ROOT="$HOME/Library/Application Support/iPhone Simulator/$IOS_VERSION"
# Find the *.app directory
APP_PATH=`find "$SIMULATOR_ROOT/Applications" -name "$APP_NAME.app"`
if [ "$APP_PATH" ]; then
# Ensure simulator isn't running whilst we remove the app
killall "iPhone Simulator"
# Get the parent directory - this will be a UUID, then remove it
APP_DIR=`dirname "$APP_PATH"`
rm -rf "$APP_DIR"
echo "Removed $APP_DIR"
else
echo "App $APP_NAME not found for platform version $IOS_VERSION"
fi
Hope that helps!

Syntax error when running RVM function

First of all, I'm running bash 3.2.48 on mac osx 10.7.1 with xCode 4 installed.
I've downloaded RVM like specified in the official documentation but when I do
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I get an error
-bash: /Users/kevin/.rvm/scripts/rvm: line 28: syntax error near unexpected token `done'
-bash: /Users/kevin/.rvm/scripts/rvm: line 28: ` done'
I've searched either on Google, the rvm github issue tracker and stackoverflow but I didn't get any info on similar issue or anything that helped me find a solution.
Nobody seems to have trouble like this installing RVM 1.8.3 so I guess something is going wrong when I install on my mac.
Here's the corresponding part of the script.
#!/usr/bin/env bash
# rvm : Ruby enVironment Manager
# https://rvm.beginrescueend.com
# https://github.com/wayneeseguin/rvm
# Is RVM loaded as a shell function already?
export HOME="${HOME%%+(\/)}" # Remove trailing slashes if they exist on HOME
if (( ${rvm_ignore_rvmrc:=0} == 0 ))
then
for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
do
if [[ -f "$rvmrc" ]]
then
if \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
then
printf "\nError:
$rvmrc is for rvm settings only.
rvm CLI may NOT be called from within $rvmrc.
Skipping the loading of $rvmrc"
return 1
else
source "$rvmrc"
fi
fi
done
fi
The error triggers on done just before the last if
Any help would be greatly appreciated.
EDIT: I found the problem, I mispelled an alias as fi. I just renamed it and it worked.
Thank you for your help. Sorry for this useless question.
I believe you're not supposed to type that but rather add it to your ~/.bash_profile at least that's how I did it on linux before, could you point where are you reading the steps for installation from?
That is correct, thats not for running at the commandline, that goes in your .bash_profile or .bashrc (with a corresponding
if [ -f "$HOME/.bashrc" ]; then
source $HOME/.bashrc
fi
in your .bash_profile)
So I decided to switch to zsh for a few reasons and it worked without doing anything but putting the line into the zshrc. But I will try to find the problem anyway.

command line IntelliJ on Mac OS X

I'm trying to launch IntelliJ on command line in Mac OS X to use it's diff tool. Theoretically idea.sh diff file1 file2 should work. In practice there are some issues with the file which I think I worked around (removing some arguments to readlink etc).
However when it does start, it wants me to enter license information (even though an instance of Intellij is already running and the license is there). Which leads me to believe that there is some sort of separation of command line world vs non-command line world on Mac OS X? IS that true?
Also when I select 30 days eval it proceeds to give me the following exception:
java.lang.IllegalArgumentException: Argument 0 for #NotNull parameter of com/intellij/openapi/fileEditor/impl/FileEditorProviderManagerImpl.getProviders must not be null
at com.intellij.openapi.fileEditor.impl.FileEditorProviderManagerImpl.getProviders(FileEditorProviderManagerImpl.java)
at com.intellij.openapi.diff.impl.highlighting.EditorPlaceHolder.setContent(EditorPlaceHolder.java:73)
at com.intellij.openapi.diff.impl.highlighting.DiffPanelState$1.run(DiffPanelState.java:38)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:864)
...
IntelliJ can install a command line launcher for you, adding it to a PATH directory would make it as any other commands on the system. The command is "idea".
Try running /Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea instead. idea.sh is not designed for Mac and will not work without some manual changes.
Another option is to create the command line launcher: Tools | Create Command-line Launcher.
If you are using Toolbox, it provides the way to create the command launcher automatically.
Try:
Tools > Create Commandline Launcher
This will create a command line launcher.
After that you can launch IntelliJ from your desired folder like with a command like this :
idea .
or
idea <path to the folder>
First step, you'll follow and click the menu, Tools > Create Commandline Launcher you'll run this command on what you want open project's directory.
idea .
Idea expects paths to be fully qualified, so I wrote a small helper script. Invoke like:
$ idiff foo.txt bar.txt
The code for idiff:
#!/bin/bash
idea='/Applications/IntelliJ IDEA 10.app/Contents/MacOS/idea'
left=`abspath $1`
right=`abspath $2`
"$idea" diff $left $right
There is probably a real abspath tool somewhere, but I have a simple hand-rolled one:
$ cat `which abspath`
#!/bin/bash
ORIG_DIR=`pwd`
for fn in $* ; do
if [ -e $fn ]; then
d=`dirname $fn`
if [ -z $d ]; then
echo `pwd`/$fn
else
cd $d
echo `pwd`"/"`basename $fn`
fi
else
echo "Don't know how to process $fn" 1>&2
exit 1
fi
cd $ORIG_DIR
done
If you have the toolbox installed, this is now controlled using the Toolbox App Settings.
First enable using the (global) toolbox app settings:
Now, you can enable at the IDE level (here using Intellij):
First you must create the shell scripts to open the IDEs, in the latest version it's done on the Toolbox
Toolbox App > Configuration > Settings > Generate shell script > export to a folder like /User/asilva/IDEs
Then you could call it like ./User/asilva/IDEs/idea or ./User/asilva/IDEs/webstorm
But if you want to call it without the absolute path, the it's needed to add it on the $PATH to be loaded every time the terminal is open:
~/.zshrc
(...)
# idea + webstorm
export PATH="/Users/asilva/IDEs:$PATH"
with this, the webstorm or idea command will be globally available

System-wide RVM to replace a home directory loaded on different architectures

I saw some questions like this already, but it seems that system-wide RVM has been deprecated, so none of the answers apply.
I have an NFS-mounted home directory which is accessible to me when I login to any number of different machines in our lab. As such, a locally-compiled Ruby will break when I try to use it on these different machines -- as they have different architectures.
I installed RVM as superuser, but I can't figure out how to direct my regular user account to use the superuser-selected Ruby. Instead it always tries to use the one in ~/bin.
What is the appropriate way to select the global Ruby?
I struggled with this same issue for quite a while. I ended up doing the following:
Install rvm with the following command line (note: the --path option is not mentioned in the usage, so I don't know how supported it is, but it worked for me), with the appropriate architecture in the path:
rvm-installer --path ~/tools/x86_64/rvm --version latest
Install for whatever architectures you want to be able to support. (note: make sure you don't have a .rvmrc file overriding the path, especially during the second install.)
Then add the following to your .bashrc/.bash_profile:
OS=$(uname -s)
if [[ $OS = Linux ]] ; then
> ARCH=$(uname -m | sed 's/i.86/i686/')
elif [[ $OS = FreeBSD ]] ; then
> ARCH=$(uname -m | sed 's/i.86/i686/')
elif [[ $OS = Darwin ]] ; then
> ARCH=mac
else
> ARCH=unknown
fi
export ARCH
There will be a line added by the installer in your .bash_profile that sets up the rvm function, change it to look like this:
[[ -s "$HOME/tools/$ARCH/rvm/scripts/rvm" ]] && . "$HOME/tools/$ARCH/rvm/scripts/rvm"
You should also edit your .rvmrc file to have the following:
export rvm_path="$HOME/tools/$ARCH/rvm"
I haven't had time to fully test out this setup, but at least it appears to be invoking the correct version of RVM on the different platforms.
Good luck!

Resources