{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/sdk/issues/968","repository_url":"https://api.github.com/repos/dotnet/sdk","labels_url":"https://api.github.com/repos/dotnet/sdk/issues/968/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/sdk/issues/968/comments","events_url":"https://api.github.com/repos/dotnet/sdk/issues/968/events","html_url":"https://github.com/dotnet/sdk/issues/968","id":213108764,"node_id":"MDU6SXNzdWUyMTMxMDg3NjQ=","number":968,"title":"Analyzers flow from dependency into referencing project","user":{"login":"twsouthwick","id":583206,"node_id":"MDQ6VXNlcjU4MzIwNg==","avatar_url":"https://avatars1.githubusercontent.com/u/583206?v=4","gravatar_id":"","url":"https://api.github.com/users/twsouthwick","html_url":"https://github.com/twsouthwick","followers_url":"https://api.github.com/users/twsouthwick/followers","following_url":"https://api.github.com/users/twsouthwick/following{/other_user}","gists_url":"https://api.github.com/users/twsouthwick/gists{/gist_id}","starred_url":"https://api.github.com/users/twsouthwick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twsouthwick/subscriptions","organizations_url":"https://api.github.com/users/twsouthwick/orgs","repos_url":"https://api.github.com/users/twsouthwick/repos","events_url":"https://api.github.com/users/twsouthwick/events{/privacy}","received_events_url":"https://api.github.com/users/twsouthwick/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dotnet/sdk/milestones/4","html_url":"https://github.com/dotnet/sdk/milestone/4","labels_url":"https://api.github.com/repos/dotnet/sdk/milestones/4/labels","id":2085837,"node_id":"MDk6TWlsZXN0b25lMjA4NTgzNw==","number":4,"title":"Unknown","description":"","creator":{"login":"srivatsn","id":20570,"node_id":"MDQ6VXNlcjIwNTcw","avatar_url":"https://avatars3.githubusercontent.com/u/20570?v=4","gravatar_id":"","url":"https://api.github.com/users/srivatsn","html_url":"https://github.com/srivatsn","followers_url":"https://api.github.com/users/srivatsn/followers","following_url":"https://api.github.com/users/srivatsn/following{/other_user}","gists_url":"https://api.github.com/users/srivatsn/gists{/gist_id}","starred_url":"https://api.github.com/users/srivatsn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srivatsn/subscriptions","organizations_url":"https://api.github.com/users/srivatsn/orgs","repos_url":"https://api.github.com/users/srivatsn/repos","events_url":"https://api.github.com/users/srivatsn/events{/privacy}","received_events_url":"https://api.github.com/users/srivatsn/received_events","type":"User","site_admin":false},"open_issues":72,"closed_issues":17,"state":"open","created_at":"2016-10-21T20:46:09Z","updated_at":"2018-07-10T22:33:21Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2017-03-09T17:26:56Z","updated_at":"2018-08-03T17:15:21Z","closed_at":null,"author_association":"MEMBER","body":"If you have a project set up as follows\r\n\r\n```\r\n- Sln\r\n  |-- ProjectA\r\n  |-- ProjectB\r\n```\r\n\r\nAnd add an analyzer to `ProjectA`, and then reference `ProjectA` in `ProjectB`, `ProjectB` also ends up having the analyzer run. Is this expected? Is there a way to turn this off for solutions where `ProjectB` does not want the analyzer to be run?"},"comment":{"url":"https://api.github.com/repos/dotnet/sdk/issues/comments/410319090","html_url":"https://github.com/dotnet/sdk/issues/968#issuecomment-410319090","issue_url":"https://api.github.com/repos/dotnet/sdk/issues/968","id":410319090,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDMxOTA5MA==","user":{"login":"nguerrera","id":75470,"node_id":"MDQ6VXNlcjc1NDcw","avatar_url":"https://avatars0.githubusercontent.com/u/75470?v=4","gravatar_id":"","url":"https://api.github.com/users/nguerrera","html_url":"https://github.com/nguerrera","followers_url":"https://api.github.com/users/nguerrera/followers","following_url":"https://api.github.com/users/nguerrera/following{/other_user}","gists_url":"https://api.github.com/users/nguerrera/gists{/gist_id}","starred_url":"https://api.github.com/users/nguerrera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nguerrera/subscriptions","organizations_url":"https://api.github.com/users/nguerrera/orgs","repos_url":"https://api.github.com/users/nguerrera/repos","events_url":"https://api.github.com/users/nguerrera/events{/privacy}","received_events_url":"https://api.github.com/users/nguerrera/received_events","type":"User","site_admin":false},"created_at":"2018-08-03T17:15:21Z","updated_at":"2018-08-03T17:15:21Z","author_association":"MEMBER","body":"@sharwell observed that PrivateAssets=\"all\" does actually work around the issue in many case.  So I took a deeper look, and it turns out that is a reasonable workaround for a common case where the analyzers come from a package with no other assets that you need to flow to consumers. \r\n\r\nConsider the Project Caller -> Project Callee -> Package Analyzers\r\n\r\nIf Callee.csproj has:\r\n``` xml\r\n    <PackageReference Include=\"Analyzers\" Version=\"1.2.3\" PrivateAssets=\"All\" />\r\n```\r\n\r\nThen Analyzers will not be picked up by project B.\r\n\r\nHowever, if a package has a mix of of both analyzers and API, then you cannot block the analyzers without also blocking the API from flowing. The reason for this is that when PrivateAssets=\"All\", then NuGet will not write out the package and its list of `\"files\"` in the `\"libraries\"` section of Caller's project.assets.json. However, if PrivateAssets is anything else, then it will write them. For non-analyzer assets, these `\"files\"` don't do matter, it is the `\"compile\"`, `\"runtime\"` lists under `\"targets\"` that do. But there is no such section for `\"analyzers\"` under `\"targets\" (NuGet/Home#6279) and so the SDK uses `\"files\"` under `\"libraries\"`, which leads to this behavior.\r\n\r\nThe irony remains that the default value of PrivateAssets is \"contentfiles;analyzers;build\", but `analyzers` do flow by default unlike `contentfiles` and `build`.\r\n\r\n\r\n"}}
{"actor":{"display_login":"nguerrera"}}