8

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?

vcsjones
  • 138,677
  • 31
  • 291
  • 286
tamaslnagy
  • 431
  • 1
  • 7
  • 16

4 Answers4

8

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.

don.najd
  • 630
  • 6
  • 12
  • Creating a symlink is probably the neatest solution if you have to use XBuild/MSBuild (which is a good to have when you want goodies like Nuget Package Restore). – sumitkm Jan 24 '13 at 20:22
  • Same goes for newer versions of Visual Studio: http://stackoverflow.com/a/35955692/200987 – oligofren Mar 12 '16 at 09:06
3

Change your csproj file to import v9.0, as so...

<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
Patrick McEvoy
  • 682
  • 6
  • 10
1

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.

Mikayla Hutchinson
  • 16,113
  • 2
  • 44
  • 50
  • If you turn off XBuild/MSBuild don't you loose out on Nuget Package Restore? You've to go back to manually restoring packages right? – sumitkm Jan 24 '13 at 20:23
0

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/
Erik A. Brandstadmoen
  • 10,430
  • 2
  • 37
  • 55