{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/7710","repository_url":"https://api.github.com/repos/aspnet/Mvc","labels_url":"https://api.github.com/repos/aspnet/Mvc/issues/7710/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/7710/comments","events_url":"https://api.github.com/repos/aspnet/Mvc/issues/7710/events","html_url":"https://github.com/aspnet/Mvc/issues/7710","id":317814993,"number":7710,"title":"Unable to test web site with Microsoft.AspNetCore.App dependency","user":{"login":"dougbu","id":6431421,"avatar_url":"https://avatars1.githubusercontent.com/u/6431421?v=4","gravatar_id":"","url":"https://api.github.com/users/dougbu","html_url":"https://github.com/dougbu","followers_url":"https://api.github.com/users/dougbu/followers","following_url":"https://api.github.com/users/dougbu/following{/other_user}","gists_url":"https://api.github.com/users/dougbu/gists{/gist_id}","starred_url":"https://api.github.com/users/dougbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dougbu/subscriptions","organizations_url":"https://api.github.com/users/dougbu/orgs","repos_url":"https://api.github.com/users/dougbu/repos","events_url":"https://api.github.com/users/dougbu/events{/privacy}","received_events_url":"https://api.github.com/users/dougbu/received_events","type":"User","site_admin":false},"labels":[{"id":70264665,"url":"https://api.github.com/repos/aspnet/Mvc/labels/wontfix","name":"wontfix","color":"ffffff","default":true}],"state":"closed","locked":false,"assignee":{"login":"JunTaoLuo","id":2030323,"avatar_url":"https://avatars1.githubusercontent.com/u/2030323?v=4","gravatar_id":"","url":"https://api.github.com/users/JunTaoLuo","html_url":"https://github.com/JunTaoLuo","followers_url":"https://api.github.com/users/JunTaoLuo/followers","following_url":"https://api.github.com/users/JunTaoLuo/following{/other_user}","gists_url":"https://api.github.com/users/JunTaoLuo/gists{/gist_id}","starred_url":"https://api.github.com/users/JunTaoLuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JunTaoLuo/subscriptions","organizations_url":"https://api.github.com/users/JunTaoLuo/orgs","repos_url":"https://api.github.com/users/JunTaoLuo/repos","events_url":"https://api.github.com/users/JunTaoLuo/events{/privacy}","received_events_url":"https://api.github.com/users/JunTaoLuo/received_events","type":"User","site_admin":false},"assignees":[{"login":"JunTaoLuo","id":2030323,"avatar_url":"https://avatars1.githubusercontent.com/u/2030323?v=4","gravatar_id":"","url":"https://api.github.com/users/JunTaoLuo","html_url":"https://github.com/JunTaoLuo","followers_url":"https://api.github.com/users/JunTaoLuo/followers","following_url":"https://api.github.com/users/JunTaoLuo/following{/other_user}","gists_url":"https://api.github.com/users/JunTaoLuo/gists{/gist_id}","starred_url":"https://api.github.com/users/JunTaoLuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JunTaoLuo/subscriptions","organizations_url":"https://api.github.com/users/JunTaoLuo/orgs","repos_url":"https://api.github.com/users/JunTaoLuo/repos","events_url":"https://api.github.com/users/JunTaoLuo/events{/privacy}","received_events_url":"https://api.github.com/users/JunTaoLuo/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/Mvc/milestones/47","html_url":"https://github.com/aspnet/Mvc/milestone/47","labels_url":"https://api.github.com/repos/aspnet/Mvc/milestones/47/labels","id":3285352,"number":47,"title":"2.1.0","description":null,"creator":{"login":"mkArtakMSFT","id":34246760,"avatar_url":"https://avatars3.githubusercontent.com/u/34246760?v=4","gravatar_id":"","url":"https://api.github.com/users/mkArtakMSFT","html_url":"https://github.com/mkArtakMSFT","followers_url":"https://api.github.com/users/mkArtakMSFT/followers","following_url":"https://api.github.com/users/mkArtakMSFT/following{/other_user}","gists_url":"https://api.github.com/users/mkArtakMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/mkArtakMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkArtakMSFT/subscriptions","organizations_url":"https://api.github.com/users/mkArtakMSFT/orgs","repos_url":"https://api.github.com/users/mkArtakMSFT/repos","events_url":"https://api.github.com/users/mkArtakMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/mkArtakMSFT/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":3,"state":"open","created_at":"2018-04-20T20:42:53Z","updated_at":"2018-05-08T15:51:19Z","due_on":null,"closed_at":null},"comments":18,"created_at":"2018-04-25T22:24:10Z","updated_at":"2018-05-09T02:04:57Z","closed_at":"2018-05-07T19:44:55Z","author_association":"MEMBER","body":"Found while verifying aspnet/Release#302.\r\n\r\n## Repro steps\r\n1. create empty folder e.g. `md netCore21RC1Api`\r\n2. `cd netCore21RC1Api`\r\n3. `dotnet new webapi --name netCore21RC1Api --output .\\netCore21RC1Api\\`\r\n4. `dotnet new xunit --name XUnitTest --output .\\XUnitTest\\`\r\n5. `dotnet new sln`\r\n6. `dotnet sln add .\\netCore21RC1Api\\netCore21RC1Api.csproj`\r\n7. `dotnet sln add .\\XUnitTest\\XUnitTest.csproj`\r\n8. ` dotnet add .\\XUnitTest\\XUnitTest.csproj reference .\\netCore21RC1Api\\netCore21RC1Api.csproj`\r\n9. `dotnet add .\\XUnitTest\\XUnitTest.csproj package Microsoft.AspNetCore.Mvc.Testing -v 2.1.0-rc1-30661`\r\n10. create an `xunit.runner.json` file in the .\\XUnitTest directory containing at least\r\n  ``` json\r\n  {\r\n    \"shadowCopy\": false\r\n  }\r\n  ```\r\n  - This setting [should](https://xunit.github.io/docs/configuring-with-json.html#items) be irrelevant for .NET Core 2.1 tests. Including it just in case&hellip;\r\n11. `dotnet build`\r\n12. Confirm app and test project work fine separately (with project reference but that's it):\r\n    a. `cd netCore21RC1Api`\r\n    b. `dotnet run --no-build`\r\n    c. browse to https://localhost:5001/api/values\r\n    d. kill the app\r\n    e. `cd ..\\XUnitTest\\`\r\n    f. `dotnet test --no-build`\r\n\r\n13. Update .\\UnitTest1.cs to contain:\r\n  ``` c#\r\n  using System;\r\n  using System.Net;\r\n  using System.Net.Http;\r\n  using System.Threading.Tasks;\r\n  using Microsoft.AspNetCore.Mvc.Testing;\r\n  using netCore21RC1Api;\r\n  using Xunit;\r\n\r\n  namespace XUnitTest\r\n  {\r\n    public class UnitTest1 : IClassFixture<WebApplicationFactory<Startup>>\r\n    {\r\n        private readonly WebApplicationFactory<Startup> _factory;\r\n\r\n        public UnitTest1(WebApplicationFactory<Startup> factory)\r\n        {\r\n            _factory = factory;\r\n        }\r\n\r\n        [Fact]\r\n        public void Test1()\r\n        {\r\n        }\r\n\r\n        [Fact]\r\n        public async Task Values_Succeeds()\r\n        {\r\n            // Arrange\r\n            var client = _factory.CreateDefaultClient();\r\n\r\n            // Act\r\n            var response = await client.GetAsync(\"/api/values\");\r\n\r\n            // Assert\r\n            Assert.Equal(HttpStatusCode.OK, response.StatusCode);\r\n        }\r\n    }\r\n  }\r\n  ```\r\n14. `dotnet build`\r\n15. `dotnet test --no-build`\r\n\r\n### Expected\r\nA successful run of both tests.\r\n\r\n### Actual\r\nThe `XUnitTest.UnitTest1.Values_Succeeds` test fails with no error given. `XUnitTest.UnitTest1.Test1` still works fine. (Both tests fail if the server is started in the constructor i.e. the `CreateDefaultClient()` was not placed in a single test.)\r\n\r\n### Execution in Visual Studio\r\nVisual Studio's Test Explorer window provides more information about the failure:\r\n![image](https://user-images.githubusercontent.com/6431421/39275499-52bacbfa-489a-11e8-9e04-33e6209521cf.png)\r\n\r\n## Details\r\n`dotnet --info`:\r\n```\r\n.NET Core SDK (reflecting any global.json):\r\n Version:   2.1.300-rc1-008662\r\n Commit:    6ae1926fb0\r\n\r\nRuntime Environment:\r\n OS Name:     Windows\r\n OS Version:  10.0.14393\r\n OS Platform: Windows\r\n RID:         win10-x64\r\n Base Path:   C:\\Program Files\\dotnet\\sdk\\2.1.300-rc1-008662\\\r\n\r\nHost (useful for support):\r\n  Version: 2.1.0-rc1-26423-06\r\n  Commit:  b50a96ee38\r\n\r\n.NET Core SDKs installed:\r\n  2.1.200-preview-007474 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.200-preview-007517 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.200-preview-007576 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.200-preview-007587 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.300-preview2-008523 [C:\\Program Files\\dotnet\\sdk]\r\n  2.1.300-rc1-008662 [C:\\Program Files\\dotnet\\sdk]\r\n\r\n.NET Core runtimes installed:\r\n  Microsoft.AspNetCore.All 2.1.0-preview2-30552 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All]\r\n  Microsoft.AspNetCore.All 2.1.0-rc1-30661 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.All]\r\n  Microsoft.AspNetCore.App 2.1.0-preview2-30552 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App]\r\n  Microsoft.AspNetCore.App 2.1.0-rc1-30661 [C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App]\r\n  Microsoft.NETCore.App 2.0.6 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n  Microsoft.NETCore.App 2.0.7 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n  Microsoft.NETCore.App 2.1.0-preview2-26403-06 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n  Microsoft.NETCore.App 2.1.0-rc1-26423-06 [C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App]\r\n\r\nTo install additional .NET Core runtimes or SDKs:\r\n  https://aka.ms/dotnet-download\r\n```"},"comment":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/387597533","html_url":"https://github.com/aspnet/Mvc/issues/7710#issuecomment-387597533","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/7710","id":387597533,"user":{"login":"JunTaoLuo","id":2030323,"avatar_url":"https://avatars1.githubusercontent.com/u/2030323?v=4","gravatar_id":"","url":"https://api.github.com/users/JunTaoLuo","html_url":"https://github.com/JunTaoLuo","followers_url":"https://api.github.com/users/JunTaoLuo/followers","following_url":"https://api.github.com/users/JunTaoLuo/following{/other_user}","gists_url":"https://api.github.com/users/JunTaoLuo/gists{/gist_id}","starred_url":"https://api.github.com/users/JunTaoLuo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JunTaoLuo/subscriptions","organizations_url":"https://api.github.com/users/JunTaoLuo/orgs","repos_url":"https://api.github.com/users/JunTaoLuo/repos","events_url":"https://api.github.com/users/JunTaoLuo/events{/privacy}","received_events_url":"https://api.github.com/users/JunTaoLuo/received_events","type":"User","site_admin":false},"created_at":"2018-05-09T02:04:57Z","updated_at":"2018-05-09T02:04:57Z","author_association":"CONTRIBUTOR","body":"Adding the Microsoft.AspNetCore.App reference and changing the sdk isn't always required to make the tests pass. @guardrex in your case, the tests work because you are referencing the .App package explicitly and specifying the version. Normally, the templates do not have a version number and our implicit version logic would have marked the package with PrivateAssets=All. Since that did not happen, all of the transitive references were maintained and your tests would be able to load any assembly that the app requires.\r\n\r\nHowever, the msbuild properties will not be flowed transitively and you can end up in a scenario where your app runs on a different framework than the tests so the recommendation is still to add a reference to Microsoft.AspNetCore.App and changing to Sdk.Web. What are the package ref error you are seeing?"}}
{"actor":{"display_login":"JunTaoLuo"}}