{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/buildtools/issues/595","repository_url":"https://api.github.com/repos/dotnet/buildtools","labels_url":"https://api.github.com/repos/dotnet/buildtools/issues/595/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/buildtools/issues/595/comments","events_url":"https://api.github.com/repos/dotnet/buildtools/issues/595/events","html_url":"https://github.com/dotnet/buildtools/pull/595","id":144672686,"number":595,"title":"Make sure code analyzers can be correctly loaded on all supported platforms.","user":{"login":"AlexGhiondea","id":8396979,"avatar_url":"https://avatars.githubusercontent.com/u/8396979?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexGhiondea","html_url":"https://github.com/AlexGhiondea","followers_url":"https://api.github.com/users/AlexGhiondea/followers","following_url":"https://api.github.com/users/AlexGhiondea/following{/other_user}","gists_url":"https://api.github.com/users/AlexGhiondea/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexGhiondea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexGhiondea/subscriptions","organizations_url":"https://api.github.com/users/AlexGhiondea/orgs","repos_url":"https://api.github.com/users/AlexGhiondea/repos","events_url":"https://api.github.com/users/AlexGhiondea/events{/privacy}","received_events_url":"https://api.github.com/users/AlexGhiondea/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/buildtools/labels/cla-already-signed","name":"cla-already-signed","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-30T17:57:14Z","updated_at":"2016-03-30T17:57:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dotnet/buildtools/pulls/595","html_url":"https://github.com/dotnet/buildtools/pull/595","diff_url":"https://github.com/dotnet/buildtools/pull/595.diff","patch_url":"https://github.com/dotnet/buildtools/pull/595.patch"},"body":"There were a couple of issues with the way analyzers were enabled:\r\n- The net core version of the analyzer was placed in the root of the Tools directory. This meant that it became part of the TPA (Trusted Platform Assemblies) list when the net core compiler was run with corerun. \r\n - This lead to a very mysterious issue where the runtime complained that it could not load the analyzer file because it could not find its dependencies.\r\n - In reality, this was caused by the fact that the assembly was part of the TPA list and the way the Roslyn compiler loads assemblies.\r\n - **Fix: Move the analyzer in a separate folder under Tools to prevent it from showing up in the TPA list.**\r\n- The property that was used to decide the path where the assembly should be loaded from was `$(BuildToolsTaskDir)`\r\n - This property however is fixed to be net45. This was needed at the time because we still depended on Mono to build our binaries on non Windows platform. \r\n - This is still required today because we still use Mono to run our tests.\r\n - **Fix: Temporarily introduce a new property that uses `$(OSEnvironment)` to decide if it should use the net45 version or the net core version for the analyzer**\r\n\r\nNote: During the investigation I noticed that the way that we load the `Microsoft.DotNet.Build.Tasks.dll` happens to work because of an implementation detail in how assemblies are being loaded.\r\nWhat happens is that when we are running on the net core msbuild, we still pass it the path to the net45 assembly. However, because there is already a file with the same simple name next to corerun, we are going to end up loading that assembly instead of the one we specified. \r\nThis is something we need to address in the future.\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/buildtools/issues/comments/203553066","html_url":"https://github.com/dotnet/buildtools/pull/595#issuecomment-203553066","issue_url":"https://api.github.com/repos/dotnet/buildtools/issues/595","id":203553066,"user":{"login":"AlexGhiondea","id":8396979,"avatar_url":"https://avatars.githubusercontent.com/u/8396979?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexGhiondea","html_url":"https://github.com/AlexGhiondea","followers_url":"https://api.github.com/users/AlexGhiondea/followers","following_url":"https://api.github.com/users/AlexGhiondea/following{/other_user}","gists_url":"https://api.github.com/users/AlexGhiondea/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexGhiondea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexGhiondea/subscriptions","organizations_url":"https://api.github.com/users/AlexGhiondea/orgs","repos_url":"https://api.github.com/users/AlexGhiondea/repos","events_url":"https://api.github.com/users/AlexGhiondea/events{/privacy}","received_events_url":"https://api.github.com/users/AlexGhiondea/received_events","type":"User","site_admin":false},"created_at":"2016-03-30T17:57:27Z","updated_at":"2016-03-30T17:57:27Z","body":"/cc @joperezr @weshaggard "}}