How can I create a NETSTANDARD2.0 project on OSX? - f#

I am definitely prefering a minimal tooling solution using VSCODE/IONIDE or FORGE.

How about dotnet new classlib -lang F# -n your_lib? .Net standard 2.0 is default. I'm not sure whether you can do that in VSCode GUI, but you sure can use integrated terminal.

Related

How to build .NET Framework ASP.NET app using dotnet

We have a mixture of ASP.NET Core and .NET Framework ASP.NET apps. We use a mixture of msbuild and dotnet to build the apps.
I'm trying to go all in on dotnet, but the build always throws an error of:
error MSB4019: The imported project "C:\Program
Files\dotnet\sdk\3.0.100-preview5-011568\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
Right now I'm just trying with a very simple command of dotnet msbuild foo.sln. No flags or anything being used for now.
I've tried this on multiple ASP.NET (not Core) apps and they all give the same error.
For ASP.NET Web applications, you need to compile using the following code.
C:\'Program Files (x86)'\'Microsoft Visual Studio'\[year]\[edition]\MSBuild\Current\Bin\msbuild.exe [project.csproj] /p:VisualStudioVersion=[version] /p:DeployOnBuild=true /p:PublishProfile=[profileName]
You can run in cmd or PowerShell.
Replace tags according to the version of Visual Studio installed on your machine and solution version.
For Example:
C:\'Program Files (x86)'\'Microsoft Visual Studio'\2019\Community\MSBuild\Current\Bin\msbuild.exe HelloWorld.csproj /p:VisualStudioVersion=16.0 /p:DeployOnBuild=true /p:PublishProfile=Release
We've solved the Microsoft.WebApplication.targets missing reference by adding it as a NuGet dependency, however the dotnet msbuild command still can't compile all related framework and asp.net projects.
We've also stood up our build server inside a docker container on an ubuntu image, as we were hoping to improve our infra with containerization etc.
However we've hit a wall in building all possible projects using the dotnet executable, even though it has the msbuild command built in.
Anyone had any luck with this?
This answer indicates this is not possible though
https://stackoverflow.com/a/66366638/6578823

Is it possible to use monogame in VS code?

I am using an iball notebook and I don't have enough memory to install Visual Studio. I am having no problems using VS code and i am able to make and create executables of my console applications. I need to learn game development but everyone keeps saying that i need to install visual studio for it
However i did find a fourm on monogame on the topic and found that it is possible(At least on Linux) to use Monogame in VS code.
http://community.monogame.net/t/visual-studio-code-and-monogame/2371
Please Help me out.I want to know if it's really possible to compile and run a monogame app in windows.
Answer edited as Monogame released official dotnet project templates
I finally got it working.
I realized that all I needed was to create a monogame project (*.csproj) and Compile/Build it without Visual Studio. VS Code is just a feature-rich text editor and I would need other toolset for it.
MSBuild tool is used to Compile/Build monogame project and is available as a CLI. It is available without installing Visual Studio.
For C# project building, dotnet core is required. executing the script
dotnet new [Template]
creates a new Project. We need to add a template for monogame here.
As per the latest update by the Monogame Team, you can install the templates by executing
dotnet new --install "MonoGame.Templates.CSharp"
Use the script
dotnet new -h
to check out all the templates available.
Now, to generate the project, use the following
dotnet new mgwindows
On successful execution, this will generate [FolderName].csproj, Game1.cs, Program.cs and other files/folders of monogame project. Please not that this csproj is on .NET Framework (version 4.5 if I'm not wrong....) and therefore it might not work with dotnet run command. (If you're a bit stubborn, you might need to copy the Monogame installed folder(which contains, among many other files, Monogame.target file) in your dotnet installed folder.)
In other words, use msbuild to build and run the project
msbuild
If the program does not contain any compile time errors, the .exe file will be built successfully and you will get to see the the Output file path which you get to execute.
If you're working on Linux or have some other reason not to use MSBuild, you should not generate a mgwindows project. You can rather chose
dotnet new desktopgl
which works on dotnet core (i.e you can use dotnet run command to execute it).
I wrote this (Windows-only) solution in medium. It's a step-by-step of how to install and run dotnet with MonoGame in the terminal of VSCode.
You need to install:
.NET SDK 5.0
.NET Core SDK 3.1
.NET Runtime 5.0
You can run dotnet in your terminal and see if it's working.
Install MonoGame editor:
dotnet tool install --global dotnet-mgcb-editor
and
mgcb-editor --register
Install MonoGame Templates:
dotnet new --install MonoGame.Templates.CSharp
Create a new project in the chosen template:
dotnet new mgdesktopgl -o ProjectName
Enter in your project with cd ProjectName and add the MonoGame package to it:
dotnet add package MonoGame.Framework.DesktopGL --version 3.8.0.1641
And finally:
dotnet run Program.cs
There is absolutely no reason you cannot work with MonoGame from Visual Studio Code. It will not be an optimal setup since you'll lack debugging, and the setup will be difficult, but if you're okay with that then continue on.
You've already noted that you have no issues creating executable console applications. This is all you really need to be able to do. The key here is that you must build targeting .NET4+ or Mono. If you've followed tutorials that lead you to building .NET Core applications they will not work with MonoGame (at this time). If you are building .NET Core, spend some time looking into how to build Desktop CLR applications using MSBuild or Mono. If you need more information I can expand upon this. You'll also need to be sure you know how to reference other .NET assemblies from your console applications. Please do some research on how to do this before moving on.
For Windows you have the option of targeting DesktopGL (OpenGL) or WindowsDX (DirectX) versions of MonoGame. I'm partial to the DirectX versions myself. You'll need 2 things to get up and running: 1. the MonoGame assemblies, and 2. the MonoGame Pipeline Tool (this is used to compile your content into .XNB files so they may be imported into your game).
To get at MonoGame's assemblies and tools the easiest way I can think of is to install Visual Studio Community Edition and then download and install MonoGame for Visual Studio. This will bring all the tools to you. You'd then need to look at "C:\Program Files (x86)\MonoGame\v3.0\Assemblies" for the appropriate assemblies and "C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools" for the MonoGame Pipeline Tool.
If Visual Studio will not let you install because your machines doesn't meet the requirements then you are not out of luck. The assemblies can be pulled in via nuget. Download the latest nuget.exe here: https://dist.nuget.org/index.html and then run: nuget.exe install MonoGame.Framework.WindowsDX or nuget.exe install MonoGame.Framework.DesktopGL. This will create a directory containing a lib folder that contains a net40 folder which contains the .DLL files you need. For WindowsDX I think you'll also need the DirectX runtime https://www.microsoft.com/en-us/download/details.aspx?id=34429. For OpenGL I think you'll need OpenAL (for audio) https://www.openal.org/downloads/.
Once you have the assemblies you'll need to reference them when you build your code. As you've said you're already familiar with creating and running console applications I'll assume you know how to do this. Just reference every managed .DLL you downloaded with Nuget or pulled from the Assemblies folder from the install.
To test things out, drop this into a .cs file, reference the MonoGame assemblies in your build, build it as you would a console application, and execute:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
public class Game1 : Game
{
GraphicsDeviceManager graphics;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
}
[STAThread]
static void Main()
{
using (var game = new Game1())
game.Run();
}
}
You should get a window with a cornflower blue background. If you don't, then you're not building or referencing things right, or you're missing a dependency.
The trick now is getting your hands on the Pipeline Tool, and MGCB.exe. If you were able to install MonoGame for Visual Studio, great!, these files are in the folder I references above. If not, for whatever reason the MonoGame project doesn't distribute stand alone versions of these, only with the installer. I've taken the contents of what you need and plopped it into a dummy release on GitHub here: https://github.com/srakowski/derp/releases/tag/MG. Download the Pipeline.zip file, extract it, and you should have what you need.
Create an empty Content.mgcb file and open it with Pipeline.exe. You should be able to add and build content files. You'll need to copy these files into the same directory where your .exe lives. Commonly, these are put into a Content folder, and Content.RootDirectory = "Content"; is added to the Game's constructor.
Once you get all this working you should be free and clear to create games as your heart desires. Please let me know if you have troubles and we'll work things out.
I've tried Monogame on Visual Studio and own a Windows PC. So I can safely confirm that Monogame does work on Windows. To answer your question.
However, if you want to try it without Visual Studio, then I don't think you can really get far. as there are several build in tools needed to make a decent one. And you cannot debug it either. You're working really limited if you cannot use Visual Studio.
Try to clean up your PC to make some free space. Visual Studio would really be a better choice to work with.

Is it possible to use TensorFlow C++ API on Windows?

I'm interested in incorporating TensorFlow into a C++ server application built in Visual Studio on Windows 10 and I need to know if that's possible.
Google recently announced Windows support for TensorFlow: https://developers.googleblog.com/2016/11/tensorflow-0-12-adds-support-for-windows.html
but from what I can tell this is just a pip install for the more commonly used Python package, and to use the C++ API you need to build the repo from source yourself: How to build and use Google TensorFlow C++ api
I tried building the project myself using bazel, but ran into issues trying to configure the build.
Is there a way to get TensorFlow C++ to work in native Windows (not using Docker or the new Windows 10 Linux subsystem, as I've seen others post about)?
Thanks,
Ian
It is certainly possible to use TensorFlow's C++ API on Windows, but it is not currently very easy. Right now, the easiest way to build against the C++ API on Windows would be to build with CMake, and adapt the CMake rules for the tf_tutorials_example_trainer project (see the source code here). Building with CMake will give you a Visual Studio project in which you can implement your C++ TensorFlow program.
Note that the tf_tutorials_example_trainer project builds a Console Application that statically links all of the TensorFlow runtime into your program. At present we have not written the necessary rules to create a reusable TensorFlow DLL, although this would be technially possible: for example, the Python extension is a DLL that includes the runtime, but does not export the necessary symbols to use TensorFlow's C or C++ APIs directly.
There is a detailed guide by Joe Antognini and a similar TensorFlow ReadMe at GitHub explaining the building of TensorFlow source via CMake. You also need to have SWIG installed on your machine which allows connecting C/C++ source with the Python scripting language. I did use Visual CMAKE (cmake-gui) with the screen capture shown below.
In the CMake configuration, I used Visual Studio 15 2017 compiler. Once this stage successfully completes, you can click on the Generate button to go ahead with the actual build process.
However, on Visual Studio 2015, when I attempted building via the "ALL_BUILD" project, the setup gave me "build tools for v141 cannot be found" error. This did not go away even when I attempted to retarget my solution. Finally, the solution got built successfully with Visual Studio 2017. You also need to manually set the SWIG_EXECUTABLE path in CMake before it successfully configures.
As indicated in the Antognini link, for me the build took about half an hour on a 16GB RAM, Core i7 machine. Once done, you might want to validate your build by attempting to run the tf_tutorials_example_trainer.exe file.
Hope this helps!
For our latest work on building TensorFlow C++ API on Windows, please look at this github page. This works on Windows 10, currently without CUDA support (only CPU).
PS:
Only the bazel build method works, because CMake is not supported and not maintained anymore, resulting in CMake configuration errors.
I had to use a downgraded version of my Visual Studio 2017 (from 15.7.5 to 15.4) by adding "VC++ 2017 version 15.4 v14.11 toolset" through the installer (Individual Components tab).
The cmake command which worked for me was:
cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^
-T "v141,version=14.11" ^
-DSWIG_EXECUTABLE="C:/Program Files/swigwin-3.0.12/swig.exe" ^
-DPYTHON_EXECUTABLE="C:/Program Files/Python/python.exe" ^
-DPYTHON_LIBRARIES="C:/Program Files/Python/libs/python27.lib" ^
-Dtensorflow_ENABLE_GPU=ON ^
-DCUDNN_HOME="C:/Program Files/cudnn-9.2-windows10-x64-v7.1/cuda" ^
-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0"
After the build, open tensorflow.sln in Visual Studio and build ALL_BUILD.
If you want to enable GPU computation, do check your Graphics Card here (Compute Capability > 3.5). Do remember to install all the packages (Cuda Toolkit 9.0, cuDNN, Python 3.7, SWIG, Git, CMake...) and add the paths to the environment variable in the beginning.
I made a README detailing how to I built the Tensorflow dll and .lib file for the C++ API on Windows with GPU support building from source with Bazel. Tensorflow version 1.14
The tutorial is step by step and starts at the very beginning, so you may have to scroll down past steps you have already done, like checking your hardware, installing Bazel etc.
Here is the url: https://github.com/sitting-duck/stuff/tree/master/ai/tensorflow/build_tensorflow_1.14_source_for_Windows
Probably you will want to scroll all the way down to this part:
https://github.com/sitting-duck/stuff/tree/master/ai/tensorflow/build_tensorflow_1.14_source_for_Windows#step-7-build-the-dll
It shows how to pass command to create .lib and .dll.
Then to test your .lib you should link it into your c++ project,
Then it will show you how to identify and fix the missing symbols using the TF_EXPORT macro
I am actively working on making this tutorial better so feel free to leave comments on this answer if you are having problems.

Is there a way to install F# 3.0 without Visual Studio?

I was hoping to upgrade to F# 3.0 but I can't find either a packaged F# 3.0 compiler on Microsoft site, nor if there is an express version to use. Is it possible to install F# 3.0 for use from the command line or a simple IDE and if so, how?
The standalone version of F# is not available yet, but F# tools for Visual Studio Express have been released just 2 days ago, so you can get F# 3.0 for free.
Announcing F# Tools for Visual Studio Express 2012 for Web!
As far as I know, there are definitely plans for open-source release (that can be integrated with MonoDevelop) and it would make sense to have a stand-alone installer too (otherwise you could still just compile the open-source release), but I don't think there are specific dates for that.
The easiest way I've got it to run:
http://www.heartysoft.com/build-fsharp-3-on-build-server-without-vs
Essentially using the direct download link on the Web PI tools.
I have successfully make a standalone F# 3.0 works without Visual Studio 2012.
First, find a workstation with F# 3.0 installed. (source)
Duplicate all the things to destination workstation.
-> C:\Program Files (x86)\Microsoft SDKs\F#
-> C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp
-> C:\Windows\Microsoft.NET\assembly\GAC_MSIL\FSharp*
Install .NET 4.5 at destination.
Export all the registry item with FSC.exe string to destination.
Export all the registry item with FSharp string to destination.
f# 3.0 registry.rar
if you don't know how to export the registry items, please download this file and use powershell to import all this .reg file.
PowerShell script: (put the .reg files into c:\xxx suppossedly )
cd c:\xxx
dir *.reg | %{ ('reg import "' + $_.Name + '"') | cmd }
I'm assuming most of you seeking an answer to this question by now probably wouldn't mind the most recent version, which is 4.0. You can download this as a standalone at F# 4.0 . This does not include the supporting assemblies and will fail by itself. So you'll also have to download and install the Microsoft Build Tools 2015 . Should be all set to go from there, no installing the mega-massive visual studio. Of course if you need an IDE you'll need to seek out a free one.
You can use Nuget CLI to install the F# Compiler Tools without relying on Visual Studio. As a plus, this procedure does not require admin rights.
Visit nuget.org/downloads and download the latest nuget.exe file.
Instruct your browser to save the file to a folder of your choice.
Add the folder where you placed nuget.exe to your PATH environment variable to use the CLI tool from anywhere.
Open a command prompt and navigate to the folder where you want to install F# Tools.
Run "nuget install FSharp.Compiler.Tools -Version {version}", where {version} is replaced with a version from https://www.nuget.org/packages/FSharp.Compiler.Tools
Add the 'tools' directory to your PATH Environment Variable and then you will be able to use fsc and fsi from the command line.
There is not currently a standalone version of F# 3.0. However, one has been promised
I run F# 3.0 from the cygwin command line on Windows 7. You need to know a little about Linux/Unix to use cygwin, but the basics are not too difficult. You need the basic cygwin shell (command interpreter) and an editor. I am used to vi, so cygwin has vim (there exists a nice F# syntax color addon to vim).
You need to:
Install visual studio in order to get F#
in /users/myname/.bashrc add the location of Fsc.exe, which in my case is
/cygdrive/c/Program Files (x86)/Microsoft SDKs/F#/3.0/Framework/v4.0
to your PATH.

Webapplication.targets missing when building a MVC4 project in MonoDevelop on OS X 10.7.4

I am trying to build a test MVC4 project on OS X 10.7.4 using Mono 2.10.9. I created a new empty MVC4 web application in Visual Studio used git to transfer the source code from Windows to Mac OS X. I then ran xbuild for .nuget package restore, but when I build in monodevelop I get a weird error:
/Users/tamasnagy/Developer/Spellbound/Spellbound/Spellbound.csproj: Error: /Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/xbuild/Microsoft/VisualStudio/v10.0/WebApplications/Microsoft.WebApplication.targets: Project file could not be imported, it was being imported by /Users/tamasnagy/Developer/Spellbound/Spellbound/Spellbound.csproj: Imported project: "/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/xbuild/Microsoft/VisualStudio/v10.0/WebApplications/Microsoft.WebApplication.targets" does not exist. (Spellbound)
What could this mean? This also happens when I simply create a new MVC project in MonoDevelop and press build. Any ideas?
Create a symlink:
cd /usr/lib/mono/xbuild/Microsoft/VisualStudio/v9.0
ln -s v9.0 v10.0
I have the same exact ubuntu 12.04 distro on two different computers and could not figure out why mono would compile on one computer and not the other. But oh well, symlink solved the problem.
Change your csproj file to import v9.0, as so...
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
Mono's MSBuild implementation (xbuild) does not have an implementation of the targets for ASP.NET projects.
You might be able to build in MonoDevelop. Make sure you have the experimental xbuild integration turned off in MonoDevelop preferences.
I know this is an old question, but it came up when searching for how to use WebApplications.targets on OSX, so it's still worth answering. With the current version of Mono (5.x), Webapplication.targets is included, so now all you have to do, is to set the VSToolsPath, and everything should just work.
If you are using standard bash shell, the .profile file is the place to put it:
export VSToolsPath=/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild/Microsoft/VisualStudio/v15.0/

Resources