1

Visual Studio Code Setup with Sansar API

So, I was discussing the possibility of the VS Code setup with Gindipple and decided to look into it. I was able to setup VS Code with the ability to get hints from the Sansar API. But, since I've also seen .NET 4.6+ mentioned for targeting for Sansar API, I've also managed to figure out how to target .NET 4.6.2 with VS Code and even successfully compile a Hello World console app with it.

Update October 7, 2017: I've included extra info for acquiring Mono.Simd to add the support to work with Sansar scripts that use it.

A basic C# Hello World console app

1. Download VS Code from https://code.visualstudio.com/

2. Follow the instructions from this video on setting up a C# project and building a basic Hello World app to confirm your setup. https://channel9.msdn.com/Blogs/dotnet/Get-started-with-VS-Code-using-CSharp-and-NET-Core

Note: The video was for an older version setup. For a basic Hello World test, you can type dotnet new console in terminal instead of the dotnet new that she mentions.

Once confirmed, now you can try a Sansar approach...

Creating a Project for Sansar Hint Support

1. Create a new project folder and instead of typing dotnet new console you type dotnet new classlib instead. I use classlib instead of console (mentioned in the new .NET Core 2 instructions) since it seems to work better for Sansar setup.

2. Acquire the Mono.Simd.dll file so that you can add the reference for your projects. You can officially download it from http://www.mono-project.com/download/ .  I downloaded the 64-bit version that doesn't have GTK#.

3. Add references to the Sansar API by editing your *.csproj file in VS Code. Currently, the code will look something like the following...

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project>

You can add the Sansar API references like so...

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Simd">
<HintPath>C:\Program Files\Mono\lib\mono\4.6.2-api\Mono.Simd.dll</HintPath>
</Reference>

<ReferenceInclude="Sansar.Script">
<HintPath>D:\Program Files\Sansar\Client\ScriptApi\Assemblies\Sansar.Script.dll</HintPath>
</Reference>
<ReferenceInclude="Sansar.Simulation">
<HintPath>D:\Program Files\Sansar\Client\ScriptApi\Assemblies\Sansar.Simulation.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

For .NET 4.6.2 support, you'll have to download and install the .NET 4.6.2 Developer Pack (https://www.microsoft.com/en-us/download/details.aspx?id=53321) and then change the *.csproj like so...

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
</PropertyGroup>
...
</Project>

Maybe someone will prefer this approach over installing Visual Studio IDE. Hopefully it helps. I'm not exactly crazy about this approach and would still prefer some basic featured editor/compiler implemented in-world, but that's just me. ;-)

14 comments

Please sign in to leave a comment.