Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omnisharp cannot locate Microsoft.WebAplication.targets and does not look at xbuild in default mono install #1597

Closed
breiter opened this issue Jun 27, 2017 · 4 comments
Assignees
Milestone

Comments

@breiter
Copy link

breiter commented Jun 27, 2017

Environment data

dotnet --info output:

dotnet --info
.NET Command Line Tools (1.0.3)

Product Information:
 Version:            1.0.3
 Commit SHA-1 hash:  37224c9917

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.3

VS Code version:

code --version
1.13.1
379d2efb5539b09112c793d3d9a413017d736f89

C# Extension version: 1.10.0

Steps to reproduce

Load a solution that includes a web project that has an import for Microsoft.WebApplication.targets

<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />

Expected behavior

All projects should load when omnisharp starts.

Visual Studio for Mac is able to load the solution without a problem.

Actual behavior

Omnisharp fails to load web project and logs a warning.

[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in /Users/breiter/src/wolfereiter/ifes-accounts-payable
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Auto package restore: False
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Update workspace context
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Resolving projects references
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBUILD_EXE_PATH environment variable set to /Users/breiter/.vscode/extensions/ms-vscode.csharp-1.10.0/bin/omnisharp/msbuild/MSBuild.dll
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuildExtensionsPath environment variable set to /Users/breiter/.vscode/extensions/ms-vscode.csharp-1.10.0/bin/omnisharp/msbuild
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuild will use local OmniSharp installation.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Detecting projects in '/Users/breiter/src/wolfereiter/ifes-accounts-payable/IFES-AccountsPayable-no-sqlproj.sln'.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: /Users/breiter/src/wolfereiter/ifes-accounts-payable/Ifes.AccountsPayable/Ifes.AccountsPayable.csproj
Discovered Mono file path: /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono
Resolved symbolic link for Mono file path: /Library/Frameworks/Mono.framework/Versions/5.0.1/bin/mono-sgen32
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Loading project: /Users/breiter/src/wolfereiter/ifes-accounts-payable/Ifes.AccountsPayable.Web/Ifes.AccountsPayable.Web.csproj
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file '/Users/breiter/src/wolfereiter/ifes-accounts-payable/Ifes.AccountsPayable.Web/Ifes.AccountsPayable.Web.csproj'.
warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to load project file '/Users/breiter/src/wolfereiter/ifes-accounts-payable/Ifes.AccountsPayable.Web/Ifes.AccountsPayable.Web.csproj'.
/Users/breiter/src/wolfereiter/ifes-accounts-payable/Ifes.AccountsPayable.Web/Ifes.AccountsPayable.Web.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/Users/breiter/.vscode/extensions/ms-vscode.csharp-1.10.0/bin/xbuild/Microsoft/VisualStudio/v14.0/WebApplications/Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  

The key issue is that the environment is resolving $(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets as /Users/breiter/.vscode/extensions/ms-vscode.csharp-1.10.0/bin/xbuild/Microsoft/VisualStudio/v14.0/WebApplications/Microsoft.WebApplication.targets which does not exist because xbuild is not encluded in the ms-vscode.csharp-1.10.0/bin directory.

It does, however, exist on my system as part of the mono distribution bundled with Visual Studio for Mac in /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild.

It doesn't help to set the "omnisharp.useMono": true option and I can't see a way to redefine the environment to look in my mono system install rather than the extension to find the .targets files.

Creating a symlink to embed the xbuild directory from mono into the extension resolves the problem:

ln -s  /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/xbuild ~/.vscode/extensions/ms-vscode.csharp-1.10.0/bin

Possibly you need to bundle the xbuild directory that mono ships with on macOS and Linux as a dependency for this extension or else have the environment detect that the xbuild directory is in a canonical location and use it.

@DustinCampbell
Copy link
Member

Thanks for the report! We still need to do work in omnisharp-roslyn to properly map the tools path in VS for Mac.

Note: setting "omnisharp.useMono" won't do anything for this scenario. That setting is for when you're using a custom OmniSharp build with C# for VS Code.

@DustinCampbell
Copy link
Member

So far, I've been unsuccessful creating a Web Application project with VS for Mac that doesn't work in VS Code. Is there some specific way I should create a Web Application project?

@breiter
Copy link
Author

breiter commented Jun 28, 2017

The projects I have tried were originally created with Visual Studio 2010 and 2013 and have rolled forward to being maintained with Visual Studio 2015 and 2017.

@DustinCampbell
Copy link
Member

I've got a fix for this in PR here: OmniSharp/omnisharp-roslyn#923. Once it's merged, it'll appear in C# for VS Code once we take a new version of OmniSharp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants