{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/msbuild/issues/1097","repository_url":"https://api.github.com/repos/Microsoft/msbuild","labels_url":"https://api.github.com/repos/Microsoft/msbuild/issues/1097/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/msbuild/issues/1097/comments","events_url":"https://api.github.com/repos/Microsoft/msbuild/issues/1097/events","html_url":"https://github.com/Microsoft/msbuild/issues/1097","id":179555629,"number":1097,"title":"Cannot use MSBuild API from a dotnet-CLI project tool","user":{"login":"natemcmaster","id":2696087,"avatar_url":"https://avatars.githubusercontent.com/u/2696087?v=3","gravatar_id":"","url":"https://api.github.com/users/natemcmaster","html_url":"https://github.com/natemcmaster","followers_url":"https://api.github.com/users/natemcmaster/followers","following_url":"https://api.github.com/users/natemcmaster/following{/other_user}","gists_url":"https://api.github.com/users/natemcmaster/gists{/gist_id}","starred_url":"https://api.github.com/users/natemcmaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natemcmaster/subscriptions","organizations_url":"https://api.github.com/users/natemcmaster/orgs","repos_url":"https://api.github.com/users/natemcmaster/repos","events_url":"https://api.github.com/users/natemcmaster/events{/privacy}","received_events_url":"https://api.github.com/users/natemcmaster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jeffkl","id":17556515,"avatar_url":"https://avatars.githubusercontent.com/u/17556515?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffkl","html_url":"https://github.com/jeffkl","followers_url":"https://api.github.com/users/jeffkl/followers","following_url":"https://api.github.com/users/jeffkl/following{/other_user}","gists_url":"https://api.github.com/users/jeffkl/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffkl/subscriptions","organizations_url":"https://api.github.com/users/jeffkl/orgs","repos_url":"https://api.github.com/users/jeffkl/repos","events_url":"https://api.github.com/users/jeffkl/events{/privacy}","received_events_url":"https://api.github.com/users/jeffkl/received_events","type":"User","site_admin":false},"assignees":[{"login":"jeffkl","id":17556515,"avatar_url":"https://avatars.githubusercontent.com/u/17556515?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffkl","html_url":"https://github.com/jeffkl","followers_url":"https://api.github.com/users/jeffkl/followers","following_url":"https://api.github.com/users/jeffkl/following{/other_user}","gists_url":"https://api.github.com/users/jeffkl/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffkl/subscriptions","organizations_url":"https://api.github.com/users/jeffkl/orgs","repos_url":"https://api.github.com/users/jeffkl/repos","events_url":"https://api.github.com/users/jeffkl/events{/privacy}","received_events_url":"https://api.github.com/users/jeffkl/received_events","type":"User","site_admin":false}],"milestone":null,"comments":25,"created_at":"2016-09-27T17:12:34Z","updated_at":"2016-11-18T23:02:08Z","closed_at":null,"body":"Using MSBuild API for in-proj project evaluation in a dotnet-CLI project tool throws this excpetion:\n\n```\nUnhandled Exception: System.TypeInitializationException: The type initializer for 'BuildEnvironmentHelperSingleton' threw an exception. ---> System.InvalidOperationException: Could not determine a valid location to MSBuild. Try running this process from the Developer Command Prompt for Visual Studio.\n   at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args)\n   at Microsoft.Build.Shared.BuildEnvironmentHelper.Initialize()\n   at Microsoft.Build.Shared.BuildEnvironmentHelper.BuildEnvironmentHelperSingleton..cctor()\n```\n\nIIUC the problem is that BuildEnvironmentHelperSingleton looks in `AppContext.BaseDirectory` (and a few other locations) for MSBuild.exe. When dotnet-CLI invokes a project tool, the AppContext.BaseDirectory will be `$(NuGetPackages)/.tools/$(ToolName)/$(ToolVersion)/netcoreapp1.0/`. The only content NuGet/CLI will put into this directory is the *.deps.json file and project.lock.json file for the tool.\n\nUsing Microsoft.Build.Runtime 15.1.262-preview5.\n\ncc @piotrpMSFT\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/msbuild/issues/comments/261664828","html_url":"https://github.com/Microsoft/msbuild/issues/1097#issuecomment-261664828","issue_url":"https://api.github.com/repos/Microsoft/msbuild/issues/1097","id":261664828,"user":{"login":"jeffkl","id":17556515,"avatar_url":"https://avatars.githubusercontent.com/u/17556515?v=3","gravatar_id":"","url":"https://api.github.com/users/jeffkl","html_url":"https://github.com/jeffkl","followers_url":"https://api.github.com/users/jeffkl/followers","following_url":"https://api.github.com/users/jeffkl/following{/other_user}","gists_url":"https://api.github.com/users/jeffkl/gists{/gist_id}","starred_url":"https://api.github.com/users/jeffkl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeffkl/subscriptions","organizations_url":"https://api.github.com/users/jeffkl/orgs","repos_url":"https://api.github.com/users/jeffkl/repos","events_url":"https://api.github.com/users/jeffkl/events{/privacy}","received_events_url":"https://api.github.com/users/jeffkl/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T23:02:08Z","updated_at":"2016-11-18T23:02:08Z","body":"Okay this is currently blocked by https://github.com/NuGet/Home/issues/3683 because our contentFiles are not being copied to the output directory.  The workaround is to set `MSBUILD_EXE_PATH` for now..."}}
{"actor":{"display_login":"jeffkl"}}