Xbuild and F # (vs2010)

I have a mixed solution VS 2010, which is primarily C #, but contains a Windows service written in F #. I had this building with xbuild in a parallel environment, but from the moment I upgraded to the packaged version of mono 2.10.5 from badgerports I could not get it to work.

I usually encounter an error:

/home/alex/git/Solution/FSProject/FSProject.fsproj: error: Target with the name "Build" was not found in the project.

What puzzles me is that, looking at the project file, it does not seem that ANY goals are defined. I am far from an MSBuild expert, but for me it is a little strange. However, he worked earlier.

Has anyone come across (and hopefully found a solution to) similar problems? If possible, I would like to be able to build a solution using xbuild and Visual Studio.

The environment is Mint 11 (not sure if this is based on ubuntu maverick or natty), performing mono 2.10.5 from barges. fsharp was set from the last source to the default prefix.

change

I managed to get a little closer thanks to the Brian pointer (I had to hardcode the path, xbuild seems to have problems resolving things like "$ (MSBuildExtensionsPath32) .. \ FSharp \ 1.0 \ Microsoft. FSharp.Targets"). FSC is actually being called now, although it complains that it cannot resolve the link to FSharp.Core.

I found this F # and XBuild (Debian) page useful to achieve this.

+4
source share
2 answers

There is no need for hackers if you use this:

+6
source

So it turns out that the parallel environment actually makes my work easier. Mono is installed in / usr, and F # is installed on / usr / local, so I need to configure symbolic links to enable FSharp targets and common goals to see each other. This is described in detail here: F # and XBuild (Debian)

Once this was set up, I still had problems. After adding some debugging messages, I found that xbuild did not correctly resolve the path to F # objects. The project file tried to import like this:

<Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="!Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition="Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> 

and xbuild ran into the problem of resolving the relative path. So I just changed it to the following:

  <Import Project="$(TargetsPath)" Condition="$(TargetsPath) != ''" /> <Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" Condition="$(TargetsPath) == '' And !Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft F#\v4.0\Microsoft.FSharp.Targets" Condition="$(TargetsPath) == '' And Exists('$(MSBuildBinPath)\Microsoft.Build.Tasks.v4.0.dll')" /> 

which allows me to pass the path to FSharp.targets on the command line.

There are still several problems (in the absence of a complaint that the elements are not being registered, I know that this is a weakness in xbuild, but it seems to be a false alarm - the project is really being created and runs successfully). Hope this helps someone else.

+3
source

Source: https://habr.com/ru/post/902053/


All Articles