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

MSBuild does not locate targets for MonoGame #1396

Closed
ambs opened this issue Apr 17, 2017 · 30 comments
Closed

MSBuild does not locate targets for MonoGame #1396

ambs opened this issue Apr 17, 2017 · 30 comments
Assignees
Milestone

Comments

@ambs
Copy link

ambs commented Apr 17, 2017

Environment data

dotnet --info output:

ambs@diabelli CourseCSharp $ dotnet --info
.NET Command Line Tools (1.0.1)

Product Information:
 Version:            1.0.1
 Commit SHA-1 hash:  005db40cd1

Runtime Environment:
 OS Name:     linuxmint
 OS Version:  18.1
 OS Platform: Linux
 RID:         ubuntu.16.04-x64
 Base Path:   /usr/share/dotnet/sdk/1.0.1

VS Code version:
$ code --version
1.11.2
6eaebe3b9c70406d67c97779468c324a7a95db0e

C# Extension version: 1.8.1

Steps to reproduce

I open code with a standard C# hello world project, write 'Console.' and no completion is shown.

Expected behavior

Expected the list of available methods from the System.Console class

Actual behavior

none.

@DustinCampbell
Copy link
Member

Hi! Could you provide your OmniSharp Log after opening this project? To display the log, select View->Output to display the Output pane and select "OmniSharp Log" from the drop-down in the top-right corner of the pane.

@DustinCampbell
Copy link
Member

Additionally, if you are using a different shell other than bash, could you let us know which one?

@ambs
Copy link
Author

ambs commented Apr 18, 2017

Just give me a couple hours to end $job, and I will give more details. Thanks!

@ambs
Copy link
Author

ambs commented Apr 18, 2017

Yes, I am using Bash.
I was trying to use code in two different ways:

  1. opening directly some .cs files that I have and compile manually
  2. opening a .csproj file

I do that, in both situations, from the command line: code file.cs / code file.csproj

In both situations, the output pane, has a dropdown with only two options, Tasks and Extensions, and both show an empty page.

Also, and this might be relevant, when doing 'code file.csproj' code opens the XML file and displays it :-O

Thanks

@DustinCampbell
Copy link
Member

Would you be willing to provide the project you're using?

Note that we don't provide completion for loose .cs files outside of project.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

OK for the loose .cs file. I was not sure, and therefore just mentioned it so you could clarify.

Not sure if you need the .csfile only, or everything, so I just uploaded my workdir here: http://eremita.di.uminho.pt/~ambs/TugEngine.tar.gz (it is a monogame project that compiles perfectly well with 'xbuild').

Thank you

@DustinCampbell DustinCampbell changed the title No completion MSBuild does not locate targets for MonoGame Apr 18, 2017
@DustinCampbell
Copy link
Member

OK. I've updated the title based on what I see on my Mac. I opened your solution and a .cs file. Then, I selected View-Output to display the VS Code Output pane and picked "OmniSharp Log" from the upper-right corner of the Output pane. In here, I see an exception like this:

Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/Users/dustincampbell/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/omnisharp/msbuild/MonoGame/v3.0/MonoGame.Content.Builder.targets" was not found. Also, tried to find "MonoGame/v3.0/MonoGame.Content.Builder.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "/Library/Frameworks/Mono.framework/External/xbuild/" . These search paths are defined in "/Users/dustincampbell/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/omnisharp/OmniSharp.exe.config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.  /Users/dustincampbell/Downloads/TugEngine/TugEngine/TugEngine.csproj
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00067] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00001] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ThrowForImportedProjectWithSearchPathsNotFound (Microsoft.Build.Evaluation.ProjectImportPathMatch searchPathMatch, Microsoft.Build.Construction.ProjectImportElement importElement) [0x000ae] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0027f] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00001] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x0036c] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate () [0x00055] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly) [0x0001a] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0003c] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00025] in <6a1392588f4a45bdbe07807130f9b3d0>:0 

Do you see something similar?

@DustinCampbell
Copy link
Member

Out of curiosity, did this work for you in the past? Or, are you new to VS Code?

@DustinCampbell
Copy link
Member

Scratch my comment about the exception. Once I installed MonoGame 3.6 on OSX, I see the project load properly and have IntelliSense working.

image

@ambs
Copy link
Author

ambs commented Apr 18, 2017

It never worked. I am new using Code (just migrated from Mac - Xamarin to Linux).
So, probably something failed during the installation of the plugin?
Thanks!

@DustinCampbell
Copy link
Member

FWIW, I'm trying Ubuntu 16.04 now.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

Hehehe, I imagine it works, as nobody else has complained. But I can't manage to get anything of it.

@DustinCampbell
Copy link
Member

We'll see. I'm also using the latest beta of C# for VS Code

@ambs
Copy link
Author

ambs commented Apr 18, 2017

Is there a way to install the beta from code, directly?

@DustinCampbell
Copy link
Member

No. You can use the instructions from here: https://github.com/OmniSharp/omnisharp-vscode/wiki/Installing-Beta-Releases.

@DustinCampbell
Copy link
Member

I had to apt-get install gtk-sharp3 and MonoGame. After doing that, I can build your project with xbuild. However, I get the same error that I listed above. Do you see the same?

@ambs
Copy link
Author

ambs commented Apr 18, 2017

I do not see any error at all :-(

@DustinCampbell
Copy link
Member

After opening the TugEngine folder and a .cs folder, you don't have an OmniSharp Log in View->Output?

@ambs
Copy link
Author

ambs commented Apr 18, 2017

ok, now I have some feedback

Starting OmniSharp server at 4/18/2017, 6:05:13 PM
    Target: /home/ambs/MyReps/TugEngine/TugEngine

OmniSharp server started wth Mono
    Path: /home/ambs/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/run
    PID: 20674

OmniSharp: -s /home/ambs/MyReps/TugEngine/TugEngine --hostPID 20516 --stdio DotNet:enablePackageRestore=false --encoding utf-8 --loglevel information formattingOptions:useTabs=false formattingOptions:tabSize=4 formattingOptions:indentationSize=4
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Startup","Message":"Omnisharp server running using Stdio at location '/home/ambs/MyReps/TugEngine/TugEngine' on host 20516."},"Seq":1,"Type":"event"}
[info]: OmniSharp.DotNet.DotNetProjectSystem
        Initializing in /home/ambs/MyReps/TugEngine/TugEngine
[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 /home/ambs/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/omnisharp/msbuild/MSBuild.dll
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuildExtensionsPath environment variable set to /home/ambs/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/omnisharp/msbuild
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuildSDKsPath environment variable set to /home/ambs/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/omnisharp/msbuild/Sdks
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        MSBuild will use local OmniSharp installation.
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        No solution files found in '/home/ambs/MyReps/TugEngine/TugEngine'
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
        Failed to process project file '/home/ambs/MyReps/TugEngine/TugEngine/TugEngine.csproj'.
/home/ambs/MyReps/TugEngine/TugEngine/TugEngine.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/home/ambs/.vscode/extensions/ms-vscode.csharp-1.9.0-beta3/bin/omnisharp/msbuild/MonoGame/v3.0/MonoGame.Content.Builder.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  /home/ambs/MyReps/TugEngine/TugEngine/TugEngine.csproj
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00067] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object arg0) [0x0000a] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object arg0) [0x00001] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpression (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.String unescapedExpression, System.Boolean throwOnFileNotExistsError, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& imports) [0x0041e] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.String unescapedExpression, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, System.Boolean throwOnFileNotExistsError) [0x0005b] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00033] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x00001] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x0036c] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate () [0x00055] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCache projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.Execution.ProjectInstance projectInstanceIfAnyForDebuggerOnly) [0x0001a] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Project.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x0003c] in <6a1392588f4a45bdbe07807130f9b3d0>:0 
  at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00025] in <6a1392588f4a45bdbe07807130f9b3d0>:0 

[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/home/ambs/MyReps/TugEngine/TugEngine'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.Startup
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.Startup
        Configuration finished.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

But still no completion :-)

@DustinCampbell
Copy link
Member

Right. That exception above is the reason why. Essentially, it's not finding the MonoGame targets file that's installed. Once it fails to find that, it bails on processing the project further.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

I think the problem so far was I was opening files and not folders (?).

So, vscode needs to find data about MonoGame but the installer did not place it in the correct place.

@DustinCampbell
Copy link
Member

No, that's unlikely. MSBuild (and xbuild -- now deprecated) have... unconventional ways of locating files. It's more likely that we need to do something in OmniSharp to locate the targets properly.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

ok, I can find that file here:
/usr/lib/mono/xbuild/MonoGame/v3.0/MonoGame.Content.Builder.targets

(msbuild or MSBuild -- command not found)

@DustinCampbell
Copy link
Member

Yup. OK. Here's a workaround for you. It's not great, but'll get your project working. Add an "omnisharp.json" file to the directory that you're opening in VS Code with the following content:

{
    "msbuild": {
        "MSBuildExtensionsPath": "/usr/lib/mono/xbuild"
    }
}

Be sure to keep that file in the root folder that you open in VS Code and it should get things working for you.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

Just great. Probably next versions can do that automatically
But for me this is fine :-) Thanks for your time!

@DustinCampbell
Copy link
Member

Cool. We'll take a look at addressing this in OmniSharp soon. In the meantime, just adding that should fix it for any MonoGame project.

@ambs
Copy link
Author

ambs commented Apr 18, 2017

I would suggest keeping this around for reference while not fixed, but if you would like, be my guest closing it.

@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.

@harry-cpp
Copy link

I never realized this was a bug.... I've been constantly just recreating symlinks to folders that contain targets file... well my life is gonna get a whole lot easier :D

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

3 participants