-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test assembly dependency resolution in .netcore #34
Comments
@AbhitejJohn @sbaid @pvlakshm @saikrishnav thoughts? |
AFAIK, dotnet publish doesn't work until specific runtime is specified. Do we want to force the users to always specify runtime in their test projects? |
@harshjain2 without a RID specified, I've updated original comment. CI build (or strictly speaking CDP) requires publish only if the |
@codito Test Adapter can have dependencies on MSTest.ObjectModel and other nuget packages. Those dependencies are taken care of if test project adds Test Adapter nuget as relevant dependencies will be added in the test dll's .deps.json file. I am not sure what will happen if user forgets to add Test Adapter. It might work if, just by luck, test dll has all the dependencies required for test adapter. Otherwise it will bomb.
|
On this, in order to ensure the dependencies of testhost is taken care of, option 1 is recommended. That way, dependencies of testhost will be present in test dll's .deps.json which we are passing when starting testhost. |
@codito @AbhitejJohn Do we know the requirements for asp.net tests? |
In Solution #2, packaging would bloat up the vstest.console bundle since it might end up having a testhost and its dependencies built for a lot of netstandard versions. #1 gives the ability to fragment this with the ability to plug in which ever version is appropriate as long as it understands the protocol. This can also be a nice host extensibility entry point where someone can specify their host via a nuget package and vstest.console can communicate with that host. One thing thats biting me with solution #1 however is the pain of the user to add 3 nuget dependencies -> Framework, Adapter and the test host. Just a thought, can we somehow tie the adapter to have a dependency on test host? That could possibly work @codito . @harshjain2 : What requirements are we talking about? Currently ASP.NET Core targets the same core CLR. I do not see any plan for post RTM here though: https://github.com/aspnet/Home/wiki/Roadmap . @codito : Does the new csproj based project system allow users to add references directly to assemblies as well? |
@harshjain2 re the dependencies of test adapter, they will cleanly resolve with I think we should take a staged approach (since this is a architectural change): start with approach 2, then move to approach 1. @AbhitejJohn @harshjain2 probably meant the assembly loading in asp.net. We will do a small spike for this. Updated notes on adapter discovery based on deps.json above. |
Will a runsettings ever be supported? I ask because that has an AssemblyResolution entry where you can specify locations where dependencies may be found. |
@pvlakshm I think we need to support runsettings since it also has platform, test logger, data collector and adapter settings. AssemblyResolution entries may not be applicable to Updated notes with two relevant specifications from dotnet-cli around runtime configuration and corehost. |
Resolved with 4f34968. |
Problem
testhost.exe
with a specifictesthost.deps.json
. In this case, user's dependencies don't resolve appropriatelyWhile this behavior is fine for desktop clr, for .netcore these premises may not work.
Impact of this bug
testproject.dll
only after adotnet publish
, so that all dependencies are copied to output directory.dotnet build
doesn't copy all dependencies to output folder.testhost.deps.json
is used,System.Xml
used bytesthost
will be loaded, although user wanted to use a later version ofSystem.Xml
. Multi-targeting will be hardProposal
(There is no change in the test platform behavior for test projects targeting
net46
or desktop clr. We concentrate only onnetcore
scenarios below)Execute testhost.dll with testproject.deps.json
In
dotnet
core, set of dependencies for a projecttestproject
are resolved withtestproject.deps.json
file available in the output path of the project. Test platform should invoketesthost.dll
with the deps file oftestproject
i.e.testproject.deps.json
.Since
testhost.dll
is always invoked withtestproject.deps.json
, it is not possible to reuse the testhost for running tests of all test projects. For each test project/container, a separatetesthost
process will be invoked. This will have a performance impact (compared to existing implementation where a single testhost process is used for running tests from all assemblies).Adapter lookup
Adapters are referenced in the
testproject
as aexclude: compile
dependency. Test platform will probe the adapter from paths intestproject.deps.json
. The lookup convention remains unchanged (*.testadapter.dll
are considered test adapters).Note that user may still provide a logger (or data collector) extension with a path. This will require the logger to be published.
Every test project depends on TestHost package
Every test project will include a
exclude: compile
type dependency onMicrosoft.TestPlatform.TestHost
nuget package. During project build, nuget takes the responsibility to compute the dependencies required for bothtestproject
andtesthost
and create thetestproject.deps.json
.testhost.dll
is always compiled with the lowestnetcoreapp
runtime. This allows it to be retargeted to any higher runtime as specified intestproject.deps.json
.CI/CDP scenario
If the tests are run on the same machine that has source enlisted and build artifacts, simple
dotnet test
should work.For CDP, where the build artifacts are consumed, a
dotnet publish
is required while publishing the artifacts. This ensures all dependencies are available fordotnet vstest
on the test machine. In this case, user needs to provide path totestproject.dll
directly.dotnet publish
for anetcore
target produces anetcoreapp1.0
directory with all dependencies. A runtime specific directory is created fornet46
target.Open questions
asp.net
test apps?References
The text was updated successfully, but these errors were encountered: