13
votes

So, I have MonoDevelop v5.7 on Linux Mint 16. I create new C# ConsoleProject with default code on it

using System;

namespace Lab1
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            Console.WriteLine ("Hello World!");
        }
    }
}

and try to build it F7. After that I have the error: Error: /../../Lab1/Lab1/Lab1.csproj: /../../Lab1/Lab1/Lab1.csproj could not import "$(MSBuildBinPath)\Microsoft.CSharp.targets" (Lab1). Does any one have any suggestions?

3
First I'd suggest running xbuild on your project in verbose mode and see what MSBuildBinPath expands to.mikalai
what version of mono do you have in your system?knocte
Do you have mono-xbuild installed?Andy

3 Answers

19
votes

I know this is late, but in my case, Mono was targeting a version of .NET that wasn't installed. This is fixed by changing the target framework.


I found the issue by running xbuild on the sln file:

xbuild myProject.sln

I got something like:

warning : Could not find project file /usr/lib/mono/3.5/Microsoft.CSharp.targets, to import. Ignoring.

The warning indicates that the project defaulted to targeting .NET 3.5, but I guess that version wasn't installed. Let's find a version that IS installed by searching for that missing file:

find /usr/lib/mono -name "Microsoft.CSharp.targets"

On my machine, /usr/lib/mono/4.5/Microsoft.CSharp.targets was listed, but you may have a different .NET version. Ignore the xbuild and msbuild paths.

Wherever it exists for you, go to your project, click the settings button next to your project in the solution pane (the dropdown button with the gear image) and click "Options". Then under "Build" you'll see "General", click that and change your "Target framework" to the .NET version where the folder contains the Microsoft.CSharp.targets file. In my case, this is 4.5.

Hopefully this helps someone.

1
votes

My problem was that I had accidentally deleted the packages.config file for the project.

0
votes

If it's a Mono Error.

So Open Project menu Choose Build-> General and choose the installed framework.

I was working on 3.5 but on mono only the 4.5 and 4.5.1 is installed.

After selection the framework I'm asked if I will continue with 2010 or 2012, you choose one of this. As the original program was written with 2008 and on 3.5 on Win7. This must be the reason. I solved by this way.