{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/msbuild/issues/3564","repository_url":"https://api.github.com/repos/Microsoft/msbuild","labels_url":"https://api.github.com/repos/Microsoft/msbuild/issues/3564/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/msbuild/issues/3564/comments","events_url":"https://api.github.com/repos/Microsoft/msbuild/issues/3564/events","html_url":"https://github.com/Microsoft/msbuild/issues/3564","id":345962624,"node_id":"MDU6SXNzdWUzNDU5NjI2MjQ=","number":3564,"title":"Custom build task is not called when building on solution level","user":{"login":"shhsu","id":6619915,"node_id":"MDQ6VXNlcjY2MTk5MTU=","avatar_url":"https://avatars1.githubusercontent.com/u/6619915?v=4","gravatar_id":"","url":"https://api.github.com/users/shhsu","html_url":"https://github.com/shhsu","followers_url":"https://api.github.com/users/shhsu/followers","following_url":"https://api.github.com/users/shhsu/following{/other_user}","gists_url":"https://api.github.com/users/shhsu/gists{/gist_id}","starred_url":"https://api.github.com/users/shhsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shhsu/subscriptions","organizations_url":"https://api.github.com/users/shhsu/orgs","repos_url":"https://api.github.com/users/shhsu/repos","events_url":"https://api.github.com/users/shhsu/events{/privacy}","received_events_url":"https://api.github.com/users/shhsu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-30T22:35:19Z","updated_at":"2018-07-31T19:26:02Z","closed_at":null,"author_association":"NONE","body":"### Steps to reproduce\r\n\r\nHi:\r\n\r\nI have created a nuget package to redistribute IIS Web Manager (currently named Microsoft.IIS.WebManager.Middleware). It's a static website. There's a build task in the nuget package that would copy the website content to a project's wwwroot directory if this nuget package is imported. The example usage was (https://github.com/shhsu/IIS.WebManager/blob/shhsu/proj/src/Microsoft.IIS.WebManager.SelfHost/Microsoft.IIS.WebManager.SelfHost.csproj)\r\n\r\nProject file\r\n```xml\r\n<Project Sdk=\"Microsoft.NET.Sdk.Web\">\r\n  <Import Project=\"$(MSBuildProjectDirectory)\\..\\build\\global.props\" />\r\n  <PropertyGroup>\r\n    <TargetFramework>netcoreapp2.1</TargetFramework>\r\n    <OutputPath>$(MSBuildProjectDirectory)\\..\\..\\artifacts\\WebManagerApp</OutputPath>\r\n  </PropertyGroup>\r\n  <ItemGroup>\r\n    <PackageReference Include=\"Microsoft.AspNetCore.App\" version=\"2.1.0\" />\r\n    <PackageReference Include=\"Microsoft.IIS.WebManager.Middleware\" Version=\"$(IISWebManagerVersion)\" PrivateAssets=\"All\" />\r\n  </ItemGroup>\r\n  <Target Name=\"PreBuild\" BeforeTargets=\"PreBuildEvent\">\r\n    <Exec Command=\"dotnet restore\" />\r\n  </Target>\r\n</Project>\r\n```\r\n\r\nDirectory contents:\r\nSee https://github.com/shhsu/IIS.WebManager/tree/shhsu/proj \r\n\r\nCommand line\r\nEdit the solution file `Microsoft.IIS.WebManager.sln` and re-enable building `Microsoft.IIS.WebManager.SelfHost` project (I disabled it because it didn't work as expected)\r\nCall:\r\n```\r\nmsbuild Microsoft.IIS.WebManager.sln\r\n```\r\n### Expected  behavior\r\n\r\nThe output directory `WebManagerApp` should contains a `wwwroot` directory.\r\n\r\n### Actual behavior\r\n\r\nThe `wwwroot` directory does not exist.\r\n\r\nNOTE: \r\nI was able to workaround the issue by disabling build of `Microsoft.IIS.WebManager.SelfHost` from solution.\r\nAnd I would call \r\n```msbuild Microsoft.IIS.WebManager.sln```\r\nand build `Microsoft.IIS.WebManager.Middleware` first, then I would build `Microsoft.IIS.WebManager.SelfHost` by itself\r\n```\r\ncd Microsoft.IIS.WebManager.SelfHost\r\ndotnet restore\r\nmsbuild\r\n```\r\n\r\nThis seem to generate the result as expected, `WebManagerApp` has the correct content in `wwwroot` directory\r\n\r\n### Environment data\r\n`msbuild /version` output: 15.7.177.53362\r\n\r\nOS info:\r\nVersion\t10.0.17134 Build 17134\r\n\r\nIf applicable, version of the tool that invokes MSBuild (Visual Studio, dotnet CLI, etc):\r\n"},"comment":{"url":"https://api.github.com/repos/Microsoft/msbuild/issues/comments/409339085","html_url":"https://github.com/Microsoft/msbuild/issues/3564#issuecomment-409339085","issue_url":"https://api.github.com/repos/Microsoft/msbuild/issues/3564","id":409339085,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTMzOTA4NQ==","user":{"login":"rainersigwald","id":3347530,"node_id":"MDQ6VXNlcjMzNDc1MzA=","avatar_url":"https://avatars1.githubusercontent.com/u/3347530?v=4","gravatar_id":"","url":"https://api.github.com/users/rainersigwald","html_url":"https://github.com/rainersigwald","followers_url":"https://api.github.com/users/rainersigwald/followers","following_url":"https://api.github.com/users/rainersigwald/following{/other_user}","gists_url":"https://api.github.com/users/rainersigwald/gists{/gist_id}","starred_url":"https://api.github.com/users/rainersigwald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rainersigwald/subscriptions","organizations_url":"https://api.github.com/users/rainersigwald/orgs","repos_url":"https://api.github.com/users/rainersigwald/repos","events_url":"https://api.github.com/users/rainersigwald/events{/privacy}","received_events_url":"https://api.github.com/users/rainersigwald/received_events","type":"User","site_admin":false},"created_at":"2018-07-31T19:26:02Z","updated_at":"2018-07-31T19:26:02Z","author_association":"CONTRIBUTOR","body":"Do I understand correctly that you're both building the NuGet package and referencing it inside the same build? That definitely won't work, because project imports can't be updated after it is loaded. That means:\r\n\r\n1. The project is loaded (because the solution references it)\r\n  a. At this time, there's no NuGet package to reference, so it's not imported.\r\n1. The PreBuild target happens, running `dotnet restore`\r\n  a. The _next_ time the project is loaded, it would see the now-restored package\r\n1. The build finishes, using the project from 1, because that's the build that was started.\r\n  a. This instance of the project doesn't have your custom target.\r\n\r\nFor your scenario, I think you'd like something like https://github.com/dotnet/sdk/issues/1151, but that doesn't currently exist."}}
{"actor":{"display_login":"rainersigwald"}}