Skip to content
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

Incremental build(?) gets in the way of Compile directive #1990

Closed
NinoFloris opened this issue Apr 18, 2017 · 5 comments
Closed

Incremental build(?) gets in the way of Compile directive #1990

NinoFloris opened this issue Apr 18, 2017 · 5 comments
Labels

Comments

@NinoFloris
Copy link

NinoFloris commented Apr 18, 2017

Because of the slow msbuild times https://github.com/dotnet/cli/issues/5918, and because there is no up to date check in the project system yet dotnet/project-system#62 I'm trying to optimize our CI times in other creative ways.

In project.json times and until I got tired of it in msbuild times we just did as many dotnet test projpath as there were test projects, however currently this pointlessly rebuilds before every dotnet build/test/run/whatever invocation. (even though incrementally built already msbuild still takes 2 seconds per project)

This is why I've created a Tests.All project that, with some glue work and tricks, imports all code from our other test projects into one project so we can run just dotnet test Tests.All saving heaps of time every test run.

The build of Tests.All fails if any of the project's code that is included via Compile Include (so not a project reference) has been built before as part of its own project.
It works if Tests.All is the 'first' project to be built (or after cleaning the obj/ folders of the compile included projects).

I'll have a small repro up in a sec

What of course should happen is that this information is ignored if we are just including a project's code

@NinoFloris
Copy link
Author

@dasMulli
Copy link
Contributor

fyi I've had success reducing build times by doing the entire workflow from MSBuild using a project file as build script: https://gist.github.com/dasMulli/69f5303aa79a8cd4060e44891c90fd2d (invoked via dotnet msbuild build.proj)

@rainersigwald
Copy link
Member

You didn't account for the exclusions of the bin and obj directories of the other projects, so the generated AssemblyInfo file for Test gets included, as well as the generated AssemblyInfo file from the Tests.All project.

From a diag log of your repro:

                     Task Parameter:
                         Sources=
                             ../Tests/obj\Debug\netcoreapp1.1\Tests.AssemblyInfo.cs
                             ../Tests/obj\Debug\netcoreapp1.1\Tests.Program.cs
                             C:\Users\raines\AppData\Local\Temp\.NETCoreApp,Version=v1.1.AssemblyAttributes.cs
                             obj\Debug\netcoreapp1.1\Tests.All.Program.cs
                             obj\Debug\netcoreapp1.1\Tests.All.AssemblyInfo.cs (TaskId:24)

Leading to the double-definition of attributes errors.

You can probably accomplish what you want with

    <Compile Include="../Tests/**/*.cs" Exclude="../**/bin/**;../**/obj/**" />

@NinoFloris
Copy link
Author

@dasMulli Nice, I'll try that some time.

For us this solution actually solves another issue as well, which is something of our own making.
We have quite slow init and teardown processes for a few projects as they need a working database before they start, but multiple projects share exactly the same schema and data and currently just set up and tear the same db down after each other. Having the project's code included in one big project saves us from that pointless exercise as well

@rainersigwald Quick response, that might just be the thing I need 😄, great!

@NinoFloris
Copy link
Author

Tested and confirmed, thank you for your great reply @rainersigwald ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants