Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify a target architecture when building projects in Visual Studio code?

I am new to VS code/F# and I am trying to build a F# console app (on both Windows workstation and on my Linux computer).

I installed the Ionide extension together with FAKE.

The code I am considering is the Iris example (see How to translate the intro ML.Net demo to F#?), creating a New F# Project with Ionide and using Microsoft.ML.

My iris.fsproj is

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
    <DebugType>portable</DebugType>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="iris.fs" />
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="..\.paket\Paket.Restore.targets" />
</Project>

When running the script (which I do with the "play" button aka F#: run script provided with VS Code/Ionide) I get:

C:\Users\MyUser\.nuget\packages\microsoft.ml\0.2.0\build\Microsoft.ML.targets(16,5): error : Microsoft.ML currently supports 'x64' processor architectures. Please ensure your application is targeting 'x64'.

together with

Running build failed. Error: System.Exception: dotnet build failed

How do I target x64 with the project structure provided by Ionide?

like image 746
Davide Fiocco Avatar asked Jun 21 '18 08:06

Davide Fiocco


People also ask

How do I change the target path in Visual Studio?

You can open *. csproject file with any text or XML editor, change the wrong path, then save the file. Then re-open the project with Visual Studio again.


1 Answers

It should be as simple as adding the following line to your PropertyGroup section:

<PlatformTarget>x64</PlatformTarget>

There are more complicated setups possible using the Condition attribute to set the platform target based on various command-line arguments to the compiler, but that should be the simplest way to get you up and running.

like image 176
rmunn Avatar answered Nov 15 '22 08:11

rmunn