Property | Value
---------|---------
Target framework identifier | `.NETCoreApp`
-Target framework version | `1.0`
-Target framework moniker | `.NETCoreApp,Version=v1.0`
+Target framework version | `3.0`
+Target framework moniker | `.NETCoreApp,Version=v3.0`
Friendly name | .NET Core Application
-NuGet folder name | `netcoreapp1.0`
-NETStandard version supported | `netstandard1.6`
+NuGet folder name | `netcoreapp3.0`
+NETStandard version supported | `netstandard2.0`
## FAQ
**Q: What is a .NET Core application?**
**Q: Can I share source between a .NET Core application, and other target frameworks?**
**A:** Yes. Most of the API supported by .NET Core application is also part of .NET Standard. That source could be compiled as a .NET Standard library and shared with a .NET Core application and a .NET Framework application as a binary. Alternatively, the source could be shared and cross-compiled between a .NET Core application and a .NET Framework application.
-**Q: Can a .NET Core application depend on more packages than just those in the `NETStandard.Library` package?**
-**A:** Yes. The contents of `NETStandard.Library` represent the standard library and are guaranteed to be supported by all platforms, including .NET Core applications, that support standard library. Packages outside of this set will be supported so long as their dependencies are provided and none are platform specific.
-
**Q: Can a .NET Core application depend on more packages than just those in the `Microsoft.NETCore.App` package?**
**A:** Yes. The contents of `Microsoft.NETCore.App` at a particular version are guaranteed to run on every platform where that version .NET Core is released. Packages outside this set can be used but don't come with that guarantee. For instance, if a package is not part of `Microsoft.NETCore.App` and needs to be cross-compiled specifically for a new OS, there is no guarantee that it will be re-released when .NET Core supports that new OS.
-**Q: Why is there only one version of `.NETCoreApp` (1.0), but there are many of `.NETStandard`?**
-**A:** `.NETStandard` is an abstract representation of API that covers all historical platforms that have ever supported that API. `.NETCoreApp` represents a concrete application type with a runnable implementation. We are shipping one version of this implementation at this point and it supports `netstandard1.6`. As we version `.NETStandard` in the future we will update the implementation of `.NETCoreApp` to support the new API and ship a new version of `.NETCoreApp`.
-
**Q: Can a .NET Core application depend on platform specific packages like `Microsoft.Win32.Registry`?**
**A:** Yes, but it will only run on the platforms that support those packages.
**Q: How is this different than `.NETCore`?**
**A:** The `.NETCore` target framework represents Windows 8, Windows 8.1, and Universal Windows Platform applications. For compatibility purposes this moniker cannot be reused for “.NET Core applications”. The branding overlap is unfortunate.
-**Q: How is this different than `DNXCore`?**
-**A:** The `DNXCore` target framework represents ASP.NET V5 applications that run in DNX and use XProj. As such the TFM already had more characteristics associated with it than those we associate with .NET Core application. .NET Core applications need not be ASP.NET applications and can run on any host and runtime supported by .NET Core.
-
**Q: How is this different than `.NETStandard`?**
**A:** The `NETStandard` target framework is an abstract target framework that represents API surface of many frameworks and platforms. As such `NETStandard` assemblies can run on any platform that supports the `NETStandard` targeted by that assembly, for example: .NET Desktop, Windows Phone, Universal Windows Platform applications, .NET Core applications, etc. `NETCoreApplication` is a concrete target framework that represents a single platform with both API surface and implementation. .NET Core applications are runnable on their own. .NETStandard libraries must be published-for or consumed-by a specific concrete target framework to be used in that type of application.
If you've made changes to coreclr make sure to also build it and pass its binaries to corefx.
```
coreclr\build -release
-corefx\build -release -- /p:CoreCLROverridePath=d:\git\coreclr\bin\Product\Windows_NT.x64.Release\
+corefx\build -c Release /p:CoreCLROverridePath=d:\git\coreclr\bin\Product\Windows_NT.x64.Release\
```
## Compile corefx with pre-compiled coreclr binaries
If you haven't made any changes to coreclr you're fine with just building corefx. This automatically picks pre-compiled coreclr binaries from MyGet.
```
-corefx\build -release
+corefx\build -c Release
```
## Create and prepare your application
3. Copy the just built corefx assemblies into your application directory. When using Visual Studio or the .NET Core SDK Host (`dotnet.exe`) you usually compile against *reference assemblies*. For simplicity we compile against the same assembly set that we use during run time.
```
-xcopy ..\corefx\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9 runtime /e /i /y /s
+xcopy ..\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9 runtime /e /i /y /s
```
You don't need all the assemblies that are built by corefx but copying the entire directory makes it easier if you want to reference additional ones. At a minimum, this app will need the following assemblies to run:
## Local Code Coverage Runs
-You can perform code coverage runs for the entire repository locally by adding the `coverage` argument to the `build -includetests` command.
+You can perform code coverage runs for the entire repository locally by adding the `coverage` switch (assuming that source and test assemblies are already built):
- build -includetests -coverage
+ build -test -coverage
-This builds and tests the test assemblies and generates the full code coverage report. The resulting index.htm file providing the results of the run should be available at:
+This runs the tests and generates the full code coverage report. The resulting index.htm file providing the results of the run should be available at:
artifacts\coverage\index.htm
As usual the generated binaries will be found in `bin/BuildOS.BuildArch.BuildType/native` as following:
- lgs@ubuntu ~/git/corefx/ ls -al ./bin/Linux.arm.Debug/native
+ lgs@ubuntu ~/git/corefx/ ls -al ./artifacts/bin/Linux.arm.Debug/native
total 988
drwxrwxr-x 2 lgs lgs 4096 3 6 18:33 .
drwxrwxr-x 3 lgs lgs 4096 3 6 18:33 ..
Many of the managed binaries are also OS-independent, e.g. System.Linq.dll, while some are OS-specific, e.g. System.IO.FileSystem.dll, with different builds for Windows and Linux.
- lgs@ubuntu ~/git/corefx/ $ ./build.sh -debug /p:BuildNative=false
+ lgs@ubuntu ~/git/corefx/ $ ./build.sh /p:BuildNative=false
The output is at `bin/[BuildConfiguration]` where `BuildConfiguration` looks something like `netcoreapp-<OSGroup>-Debug-<Architecture>`. Ex: `bin/netcoreapp-Linux-Debug-x64`. For more details on the build configurations see [project-guidelines](../coding-guidelines/project-guidelines.md)
--buildConfig=Release
```
-The Linux ARM Emulator is based on the soft floating point and thus the native binaries are generated for the armel architecture. The corefx binaries generated by the above command can be found at `~/corefx/bin/Linux.armel.Release`, `~/corefx/bin/Linux.AnyCPU.Release`, `~/corefx/bin/Unix.AnyCPU.Release`, and `~/corefx/bin/AnyOS.AnyCPU.Release`.
+The Linux ARM Emulator is based on the soft floating point and thus the native binaries are generated for the armel architecture. The corefx binaries generated by the above command can be found at `~/corefx/artifacts/bin/Linux.armel.Release`, `~/corefx/artifacts/bin/Linux.AnyCPU.Release`, `~/corefx/artifacts/bin/Unix.AnyCPU.Release`, and `~/corefx/artifacts/bin/AnyOS.AnyCPU.Release`.
Build corefx for a new architecture
Example building for armel
```
src/Native/build-native.sh armel
---> Output goes to bin/runtime/netcoreapp-Linux-Debug-armel
+--> Output goes to artifacts/bin/runtime/netcoreapp-Linux-Debug-armel
build /p:ArchGroup=x64 /p:BuildNative=false
---> Output goes to bin/runtime/netcoreapp-Linux-Debug-x64
+--> Output goes to artifacts/bin/runtime/netcoreapp-Linux-Debug-x64
```
The reason you need to build the managed portion for x64 is because it depends on runtime packages for the new architecture which don't exist yet so we use another existing architecture such as x64 as a proxy for building the managed binaries.
Calling the script `build.sh` builds both the native and managed code.
-For more information about the different options when building, run `build.sh -?` and look at examples in the [developer-guide](../project-docs/developer-guide.md).
+For more information about the different options when building, run `build.sh --help` and look at examples in the [developer-guide](../project-docs/developer-guide.md).
## Minimum Hardware Requirements
- 2GB RAM
Note that when calling the script `build.cmd` attempts to build both the native and managed code.
-For more information about the different options when building, run `build.cmd -?` and look at examples in the [developer-guide](../project-docs/developer-guide.md).
+For more information about the different options when building, run `build.cmd -help` and look at examples in the [developer-guide](../project-docs/developer-guide.md).
### Running tests from the command line
To run a test from a single Build Pivot combination, specify all properties and build the `csproj`:
```
-dotnet msbuild System.Net.ServicePoint.Tests.csproj /t:rebuildandtest /p:TargetGroup=netcoreapp2.0 /p:Outerloop=true /p:xunitoptions=-showprogress /p:ConfigurationGroup=Debug
+dotnet msbuild System.Net.ServicePoint.Tests.csproj /t:rebuildandtest /p:TargetGroup=netcoreapp2.0 /p:OuterLoop=true /p:xunitoptions=-showprogress /p:ConfigurationGroup=Debug
```
Will run the test using the following pivot values:
* Architecture: AnyCPU
* `*System.Threading.Tasks.Dataflow.DataflowEventSource {16F53577-E41D-43D4-B47E-C17025BF4025}`: Provides an event source for tracing Dataflow information.
## Notes
-* You can find the test invocation command-line by looking at the logs generated after the `dotnet msbuild /t:rebuild,test` within the test folder.
+* You can find the test invocation command-line by looking at the logs generated after the `dotnet msbuild /t:rebuildandtest` within the test folder.
Since `0.11.1` BenchmarkDotNet knows how to run benchmarks with CoreRun. So you just need to provide it the path to CoreRun! The simplest way to do that is via console line arguments:
- dotnet run -c Release -f netcoreapp3.0 -- -f *MyBenchmarkName* --coreRun "C:\Projects\corefx\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe"
+ dotnet run -c Release -f netcoreapp3.0 -- -f *MyBenchmarkName* --coreRun "C:\Projects\corefx\artifacts\bin\testhost\netcoreapp-Windows_NT-Release-x64\shared\Microsoft.NETCore.App\9.9.9\CoreRun.exe"
**Hint:** If you are curious to know what BDN does internally you just need to apply `[KeepBenchmarkFiles]` attribute to your class or set `KeepBenchmarkFiles = true` in your config file. After running the benchmarks you can find the auto-generated files in `%pathToBenchmarkApp\bin\Release\$TFM\` folder.
1. Before you start benchmarking the code you need to build entire CoreFX in Release which is going to generate the right CoreRun bits for you:
- C:\Projects\corefx>build.cmd -release /p:ArchGroup=x64
+ C:\Projects\corefx>build.cmd -c Release -arch x64
After that, you should be able to find `CoreRun.exe` in a location similar to:
2. Build entire CoreFX in Release using your local private build of coreclr (See [Testing With Private CoreCLR Bits](https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md#testing-with-private-coreclr-bits))
- C:\Projects\corefx>build.cmd -release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release
+ C:\Projects\corefx>build.cmd -c Release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release
After that, you should be able to find `CoreRun.exe` in a location similar to:
- Rebuild given CoreFX part in Release:
- C:\Projects\corefx>build.cmd -release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release
+ C:\Projects\corefx>build.cmd -c Release /p:CoreCLROverridePath=C:\Projects\coreclr\bin\Product\Windows_NT.x64.Release
- OR manually copy over the relevant files from within the root of the coreclr output folder to where `CoreRun.exe` lives within corefx (excluding the subdirectories). This ends up being much faster than the first option and if the only thing that changed is `System.Private.Corelib.dll`, just copy that over:
+++ /dev/null
-[Consumes API specification](https://github.com/dotnet/buildtools/blob/master/Documentation/RepoCompose.md#consumes-1)
-
-In CoreFx, we'll be using the RepoUtil tool to generate consumes data. RepoUtil examines all of the repo's project.json
-files to determine external dependencies.
-
-We have a lot of differing package dependency versions on libraries in our tree (ie test-runtime, ref assembly packages,
-implementation packages, etc...). Our stable versioned dependencies will become fixed package outputs in the consumes API. Prerelease fixed packages will still need to be listed in the "fixedPackages" section of RepoData.json.
The CoreFX repo can be built from a regular, non-admin command prompt. The build produces multiple binaries that make up the CoreFX libraries and the accompanying tests.
-Developer Workflow
-------------------
-The dev workflow describes the [development process](https://github.com/dotnet/buildtools/blob/master/Documentation/Dev-workflow.md) to follow. It is divided into specific tasks that are fast, transparent and easy to understand.
-
-For more information about the different options that each task has, use the argument `-?` when calling the script. For example:
+For information about the different options that are available use the argument `-help|-h` when calling the build script:
```
-build -?
+build -h
```
### Build
The build configurations are generally defaulted based on where you are building (i.e. which OS or which architecture) but we have a few shortcuts for the individual properties that can be passed to the build scripts:
-- `-framework` identifies the target framework for the build. It defaults to `netcoreapp` but possible values include `netcoreapp`, `netfx` or `uap`. (msbuild property `TargetGroup`)
+- `-framework|-f` identifies the target framework for the build. It defaults to `netcoreapp` but possible values include `netcoreapp`, `netfx` or `uap`. (msbuild property `TargetGroup`)
- `-os` identifies the OS for the build. It defaults to the OS you are running on but possible values include `Windows_NT`, `Unix`, `Linux`, or `OSX`. (msbuild property `OSGroup`)
-- `-debug|-release` controls the optimization level the compilers use for the build. It defaults to `Debug`. (msbuild property `ConfigurationGroup`)
-- `/p:ArchGroup` identifies the architecture for the build. It defaults to `x64` but possible values include `x64`, `x86`, `arm`, or `arm64`. (msbuild property `ArchGroup`)
+- `-configuration|-c Debug|Release` controls the optimization level the compilers use for the build. It defaults to `Debug`. (msbuild property `ConfigurationGroup`)
+- `-arch` identifies the architecture for the build. It defaults to `x64` but possible values include `x64`, `x86`, `arm`, or `arm64`. (msbuild property `ArchGroup`)
For more details on the build configurations see [project-guidelines](../coding-guidelines/project-guidelines.md#build-pivots).
-**Note**: Before working on individual projects or test projects you **must** run `build` from the root once before beginning that work. It is also a good idea to run `build` whenever you pull a large set of unknown changes into your branch.
+**Note**: Before working on individual projects or test projects you **must** run `build` from the root once before beginning that work. It is also a good idea to run `build` whenever you pull a large set of unknown changes into your branch. If you invoke the build script without any actions, the default action chain `-restore -build` is executed. This means that restore and build are not implicit when invoking other actions!
+
+**Note:** You can chain multiple actions together but the order of execution is fixed and does not relate to the position of the argument in the command.
The most common workflow for developers is to call `build` from the root once (preceded by a `clean -all` if you have built previously) and then go and work on the individual library that you are trying to make changes for. On windows folks will usually open up the solution file in the root of that library directory and work in VS.
-By default build only builds the product libraries and none of the tests if you want to build and run all the tests you can call `build -test` to build and run only the tests or `build -includetests` to build the project as well as the tests
+By default build only builds the product libraries and none of the tests. If you want to build the tests you can call `build -buildtests`. If you want to run the tests you can call `build -test`, `build -integrationTest` or `build -performanceTest`. To build and run the tests combine both arguments: `build -buildtests -test`. To build both the product libraries and the test libraries pass `build -build -buildtests` to the command line. If you want to further configure which test libraries to build you can pass `/p:TestProjectFilter=Tests|IntegrationTests|PerformanceTests` to the command.
+
+If you invoke the build script without any argument the default arguments will be executed `-restore -build`. Note that -restore and -build are only implicit if no actions are passed in.
**Examples**
- Clean and build the product libraries
build
```
-- Building in debug mode for platform x64
+- Building in release mode for platform x64 (restore and build are implicit here as no actions are passed in)
```
-build -debug /p:ArchGroup=x64
+build -c Release -arch x64
```
-- Building the src and then building and running the tests
+- Building the src assemblies and build and run tests (running all tests takes a considerable amount of time!)
```
-build -includetests
+build -restore -build -buildtests -test
```
-- Building for different target frameworks
+- Building for different target frameworks (restore and build are implicit again as no action is passed in)
```
build -framework netcoreapp
build -framework netfx
**Examples**
- The following shows how to build only the tests but not run them
```
-build -test -skiptests
+build -buildtests
```
- The following builds and runs all tests for netcoreapp in release configuration.
```
-build -test -release -framework=netcoreapp
+build -buildtests -test -c Release -f netcoreapp
```
- The following example shows how to pass extra msbuild properties to ignore tests ignored in CI.
- All the options listed above like framework and configuration are also supported (note they must be after the directory)
```
-build System.Collections -framework:netfx -release
+build System.Collections -f netfx -c Release
```
### Building individual projects
### Building all for other OSes
By default, building from the root will only build the libraries for the OS you are running on. One can
-build for another OS by specifying `build /p:OSGroup=[value]`.
+build for another OS by specifying `build -os [value]`.
Note that you cannot generally build native components for another OS but you can for managed components so if you need to do that you can do it at the individual project level or build all via passing `/p:BuildNative=false`.
### Building in Release or Debug
By default, building from the root or within a project will build the libraries in Debug mode.
-One can build in Debug or Release mode from the root by doing `build -release` or `build -debug` or when building a project by specifying `/p:ConfigurationGroup=[Debug|Release]` after the `dotnet msbuild` command.
+One can build in Debug or Release mode from the root by doing `build -c Release` or `build -c Debug` or when building a project by specifying `/p:ConfigurationGroup=[Debug|Release]` after the `dotnet msbuild` command.
### Building other Architectures
-One can build 32- or 64-bit binaries or for any architecture by specifying in the root `build /p:ArchGroup=[value]` or in a project `/p:ArchGroup=[value]` after the `dotnet msbuild` command.
+One can build 32- or 64-bit binaries or for any architecture by specifying in the root `build -arch [value]` or in a project `/p:ArchGroup=[value]` after the `dotnet msbuild` command.
### Tests
-We use the OSS testing framework [xunit](http://xunit.github.io/) with the [BuildTools test targets](https://github.com/dotnet/buildtools/blob/master/Documentation/test-targets-usage.md).
+We use the OSS testing framework [xunit](http://xunit.github.io/).
#### Running tests on the command line
-Do build tests you need to pass `-test` flag (`build -test`) to build.cmd/sh or if you want to build both you pass `-includetests` flag (`build -includetests`).
+To build tests you need to pass the `-buildtests` flag to build.cmd/sh or if you want to build both src and tests you pass `-buildtests` flag (`build -restore -build -buildtests`). Note that you need to specify -restore and -build additionally as those are only implicit if no action is passed in.
For more information about cross-platform testing, please take a look [here](https://github.com/dotnet/corefx/blob/master/Documentation/building/cross-platform-testing.md).
The tests can also be filtered based on xunit trait attributes defined in [`Microsoft.DotNet.XUnitExtensions`](https://github.com/dotnet/arcade/tree/master/src/Microsoft.DotNet.XUnitExtensions). These attributes are specified above the test method's definition. The available attributes are:
-#### OuterloopAttribute
+#### OuterLoopAttribute
```cs
[OuterLoop()]
```
-Tests marked as `Outerloop` are for scenarios that don't need to run every build. They may take longer than normal tests, cover seldom hit code paths, or require special setup or resources to execute. These tests are excluded by default when testing through `dotnet msbuild` but can be enabled manually by adding the `Outerloop` property e.g.
+Tests marked as `OuterLoop` are for scenarios that don't need to run every build. They may take longer than normal tests, cover seldom hit code paths, or require special setup or resources to execute. These tests are excluded by default when testing through `dotnet msbuild` but can be enabled manually by adding the `-outerloop` switch or `/p:OuterLoop=true` e.g.
```cmd
-build -test -Outerloop
-```
-
-To run <b>only</b> the Outerloop tests, use the following command:
-```cmd
-dotnet msbuild <csproj_file> /t:BuildAndTest /p:WithCategories=OuterLoop
+build -test -outerloop
+cd src/System.Text.RegularExpressions/tests && dotnet msbuild /t:RebuildAndTest /p:OuterLoop=true
```
#### PlatformSpecificAttribute
dotnet msbuild <csproj_file> /t:BuildAndTest /p:OSGroup=OSX /p:WithCategories="OuterLoop;failing""
```
-Alternatively, you can directly invoke the XUnit executable by changing your working directory to the test execution directory at `bin\tests\{OSPlatformConfig)\{Project}.Tests\{TargetGroup}.{TestTFM}\` which is created when the test project is built. For example, the following command runs all Linux-supported inner-loop tests:
-```sh
-./corerun xunit.console.dll <test_dll_file> -notrait category=nonlinuxtests -notrait category=OuterLoop
-```
-
### Code Coverage
Code coverage is built into the corefx build system. It utilizes OpenCover for generating coverage data and ReportGenerator for generating reports about that data. To run:
```cmd
-:: Run full coverage
-build -test -Coverage
+:: Run full coverage (assuming sources and tests are already built)
+build -test -coverage
If coverage succeeds, the full report can be found at `artifacts\coverage\index.htm`.
+++ /dev/null
-Open Source Signing
-===================
-
-Documentation moved to [Public Signing](public-signing.md).
-
-----------
Performance test files (if present) are stored within a library's ```tests/Performance``` directory and contain test methods that are all marked with a perf-specific *Benchmark* attribute.
-**Step # 1:** Prior to running performance tests, a full build from the repo root must be completed: ```build -release```
+**Step # 1:** Prior to running performance tests, a full build from the repo root must be completed: `build -c Release`
**Step # 2:** Change directory to the performance tests directory: ```cd path/to/library/tests/Performance```
**Step # 3:** Build and run the tests:
- - Windows ```dotnet msbuild /t:BuildAndTest /p:ConfigurationGroup=Release```
- - Linux: ```dotnet msbuild /t:BuildAndTest /p:ConfigurationGroup=Release```
-
-**Note: Because test build runs tests concurrently, do not use it for executing performance tests. If you still want to run them concurrently you need to pass the flag `/p:Performance=true` to it: `build -test -release /p:Performance=true`.**
+ - Windows ```dotnet msbuild /t:BuildAndPerformanceTest /p:ConfigurationGroup=Release```
+ - Linux: ```dotnet msbuild /t:BuildAndPerformanceTest /p:ConfigurationGroup=Release```
The results files will be dropped in corefx/artifacts/bin/tests/TESTLIBRARY/FLAVOR/. The console output will also specify the location of these files.
+To build and run all tests from root, execute the following command: `build -performanceTest -buildtests -c Release`.
+
**Getting memory usage**
To see memory usage as well as time, add the following property to the command lines above: `/p:CollectFlags=stopwatch+gcapi`.
+++ /dev/null
-Project NuGet Dependencies
-==========================
-
-Documentation moved to [Project NuGet Dependencies](https://github.com/dotnet/buildtools/blob/master/Documentation/project-nuget-dependencies.md).
+++ /dev/null
-this document has moved to [net-platform-standard.md](../architecture/net-platform-standard.md)
\ No newline at end of file
}
```
-# Outerloop
-This one is fairly simple but often used incorrectly. When running tests which depend on outside influences like e.g. Hardware (Internet, SerialPort, ...) and you can't mitigate these dependencies, you might consider using the `[Outerloop]` attribute for your test.
+# OuterLoop
+This one is fairly simple but often used incorrectly. When running tests which depend on outside influences like e.g. Hardware (Internet, SerialPort, ...) and you can't mitigate these dependencies, you might consider using the `[OuterLoop]` attribute for your test.
With this attribute, tests are executed in a dedicated CI loop and won't break the default CI loops which get created when you submit a PR.
-To run Outerloop tests locally you need to set the msbuild property "Outerloop" to true: `/p:Outerloop=true`.
-To run Outerloop tests in CI you need to mention dotnet-bot and tell him which tests you want to run. See `@dotnet-bot help` for the exact loop names.
+To run OuterLoop tests locally you need to set the msbuild property "OuterLoop" to true: `/p:OuterLoop=true`.
+To run OuterLoop tests in CI you need to mention dotnet-bot and tell him which tests you want to run. See `@dotnet-bot help` for the exact loop names.
-This doesn't mean that you should mark every test which executes against a remote endpoint as Outerloop. See below.
+This doesn't mean that you should mark every test which executes against a remote endpoint as OuterLoop. See below.
# Relay Server
For network related tests which needs to contact a remote endpoint instead of a LoopbackServer, you can use our Relay Servers. We invest in Infrastructure to provide these "safe" remote endpoints.
# _outerloop: true | false
# Required: submitToHelix -> Boolean -> Value to know if it should submit tests payloads to helix.
-
+
# Optional: buildScriptPrefix -> String -> string to append to Unix build script.
# buildScriptPrefix: 'HOME=/home/ ' -> 'HOME=/home/ ./build.sh ...'
# Optional: enableMicrobuild -> Boolean - if microbuild plugin for signing should be enabled
# Default: false
-
+
# Optional: preBuildSteps -> Array -> list of steps to be executed before common build steps.
# In example, to install build dependencies, or setup an environment.
# preBuildSteps:
- name: ${{ pair.key }}
value: ${{ pair.value }}
+ - _archiveTestsParameter: ''
+
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
- _msbuildCommonParameters: /p:OfficialBuildId=$(Build.BuildNumber)
- ${{ if eq(parameters.isOfficialBuild, 'false') }}:
- ${{ if eq(job.submitToHelix, 'true') }}:
- group: DotNet-HelixApi-Access
+ - _archiveTestsParameter: /p:ArchiveTests=Tests
# Windows variables
- ${{ if eq(parameters.targetOS, 'Windows_NT') }}:
- _buildScript: build.cmd
- - _commonArguments: -ci -includetests -configuration $(_BuildConfig)
+ - _commonArguments: -restore -build -configuration $(_BuildConfig) -ci -buildtests -arch $(_architecture)
- _msbuildCommand: powershell -ExecutionPolicy ByPass -NoProfile eng\common\msbuild.ps1 -warnaserror:0 -ci
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
# Non-Windows variables
- ${{ if ne(parameters.targetOS, 'Windows_NT') }}:
- _buildScript: ${{ job.buildScriptPrefix }}./build.sh
- - _args: --ci -includetests --configuration $(_BuildConfig)
+ - _args: --restore --build --configuration $(_BuildConfig) --ci --buildtests --arch $(_architecture)
- _commonArguments: $(_args)
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
- - _commonArguments: $(_args) -stripSymbols
+ - _commonArguments: $(_args) --stripSymbols
- _msbuildCommand: ${{ job.buildScriptPrefix }}./eng/common/msbuild.sh --warnaserror false --ci
- _windowsOfficialBuildArguments: ''
- ${{ job.preBuildSteps }}
- ${{ if eq(job.customBuildSteps[0], '') }}:
-
+
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
- task: NuGetToolInstaller@0
inputs:
- script: $(_buildScript)
$(_commonArguments)
- -framework $(_framework)
- /p:ArchGroup=$(_architecture)
- /p:ConfigurationGroup=$(_BuildConfig)
- /p:SkipTests=$(_skipTests)
- /p:Outerloop=$(_outerloop)
- /p:ArchiveTests=${{ job.submitToHelix }}
+ -f $(_framework)
+ /p:OuterLoop=$(_outerloop)
+ $(_archiveTestsParameter)
${{ job.buildExtraArguments }}
$(_msbuildCommonParameters)
$(_windowsOfficialBuildArguments)
helixToken: ''
# TODO: Enable azure pipelines reporter for PRs once retry feature is available.
enableAzurePipelinesReporter: false
-
+
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
- task: PublishBuildArtifacts@1
displayName: Publish packages to artifacts container
/p:ArchGroup=${{ parameters.archGroup }}
/p:ConfigurationGroup=${{ parameters.configuration }}
/p:OSGroup=${{ parameters.targetOS }}
- /p:Outerloop=${{ parameters.outerloop }}
+ /p:OuterLoop=${{ parameters.outerloop }}
/p:TargetGroup=${{ parameters.framework }}
/p:HelixTargetQueues=${{ parameters.helixQueues }}
/p:HelixBuild=$(Build.BuildNumber)
_helixQueues: $(linuxArm64Queues)
_dockerContainer: ubuntu_1604_arm64_cross_container
_buildScriptPrefix: 'ROOTFS_DIR=/crossrootfs/arm64 '
- _buildExtraArguments: ''
+ _buildExtraArguments: --warnAsError false
${{ if eq(parameters.isOuterloopBuild, 'true') }}:
x64_Debug:
_helixQueues: $(linuxArm64Queues)
_dockerContainer: ubuntu_1604_arm64_cross_container
_buildScriptPrefix: 'ROOTFS_DIR=/crossrootfs/arm64 '
- _buildExtraArguments: ''
+ _buildExtraArguments: --warnAsError false
${{ if eq(parameters.isOfficialBuild, 'true') }}:
musl_x64_Release:
_BuildConfig: Release
_architecture: arm
_framework: netcoreapp
- _buildExtraArguments: /p:RuntimeOS=ubuntu.16.04
+ _buildExtraArguments: /p:RuntimeOS=ubuntu.16.04 --warnAsError false
_buildScriptPrefix: 'ROOTFS_DIR=/crossrootfs/arm '
_dockerContainer: ubuntu_1604_arm_cross_container
- netcoreappWindowsQueues: Windows.7.Amd64.Open+Windows.81.Amd64.Open+Windows.10.Amd64.ClientRS4.ES.Open
- nanoQueues: Windows.10.Nano.Amd64.Open
- uapNetfxQueues: Windows.10.Amd64.ClientRS5.Open
-
+
- ${{ if eq(parameters.isOfficialBuild, 'true') }}:
- netcoreappWindowsQueues: Windows.7.Amd64+Windows.81.Amd64+Windows.10.Amd64.Core+Windows.10.Amd64.ClientRS4
- nanoQueues: Windows.10.Nano.Amd64
customBuildSteps:
- script: build.cmd
+ -restore
+ -build
+ -configuration $(_BuildConfig)
-ci
- -$(_framework)
- /p:ArchGroup=$(_architecture)
- /p:ConfigurationGroup=$(_BuildConfig)
+ -buildtests
+ -allconfigurations
+ -arch $(_architecture)
/p:RuntimeOS=win10
+ /p:ArchiveTests=Packages
$(_windowsOfficialBuildArguments)
$(_msbuildCommonParameters)
- displayName: Build Packages
- - script: build.cmd
- -ci
- -test
- -$(_framework)
- /p:ArchGroup=$(_architecture)
- /p:ConfigurationGroup=$(_BuildConfig)
- /p:ArchiveTests=true
- displayName: Build test projects
+ displayName: Build Packages and Tests
- ${{ if eq(parameters.isOfficialBuild, 'false') }}:
- script: build.cmd
+ -restore
+ -build
+ -configuration $(_BuildConfig)
-ci
- -test
- /p:TargetGroup=netstandard
- /p:ArchGroup=$(_architecture)
- /p:ConfigurationGroup=$(_BuildConfig)
- /p:SkipTests=true
+ -buildtests
+ -framework netstandard
+ -arch $(_architecture)
displayName: Build Netstandard Test Suite
# TODO: UAPAOT official builds should send to helix using continuation runner.
function BuildAndTestBinary
{
- $output = (msbuild /t:rebuild,test /p:Outerloop=true)
+ $output = (msbuild /t:rebuild,test /p:OuterLoop=true)
if ($lastexitcode -ne 0)
{
throw "Build/test failed."
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>CoreFx.Private.TestUtilities</AssemblyName>
<ProjectGuid>{EBDB0247-CA43-4226-B7A1-8FEF21061D09}</ProjectGuid>
<Compile Include="System\IO\FileCleanupTestBase.cs" />
<Compile Include="System\Diagnostics\RemoteExecutorTestBase.cs" />
<Compile Include="System\Net\PlatformDetection.Networking.cs" />
+ <Compile Include="System\PlatformApis.Unix.cs" Condition="'$(TargetsWindows)' != 'true'" />
<Compile Include="System\TestEnvironment.cs" />
<Compile Condition="'$(TargetGroup)' == 'netcoreapp' OR '$(TargetGroup)' == 'netcoreapp2.0'" Include="System\Diagnostics\RemoteExecutorTestBase.netcore.cs" />
<Compile Condition="'$(TargetGroup)' == 'netfx'" Include="System\Diagnostics\RemoteExecutorTestBase.netfx.cs" />
<ReferenceFromRuntime Include="xunit.core" />
<ReferenceFromRuntime Include="$(MicrosoftDotNetXUnitExtensionsPackage)" />
<ReferenceFromRuntime Include="xunit.assert" />
- <ReferenceFromRuntime Condition="'$(TargetGroup)' != 'uapaot'" Include="Microsoft.DotNet.PlatformAbstractions" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' != 'netfx'">
<Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.IO;
+using System.Runtime.InteropServices;
+
+namespace System
+{
+ internal static class PlatformApis
+ {
+ private enum Platform
+ {
+ Unknown = 0,
+ Linux = 2,
+ Darwin = 3,
+ FreeBSD = 4
+ }
+
+ private static partial class NativeMethods
+ {
+ public static class Darwin
+ {
+ private const int CTL_KERN = 1;
+ private const int KERN_OSRELEASE = 2;
+
+ public unsafe static string GetKernelRelease()
+ {
+ const uint BUFFER_LENGTH = 32;
+
+ var name = stackalloc int[2];
+ name[0] = CTL_KERN;
+ name[1] = KERN_OSRELEASE;
+
+ var buf = stackalloc byte[(int)BUFFER_LENGTH];
+ var len = stackalloc uint[1];
+ *len = BUFFER_LENGTH;
+
+ try
+ {
+ // If the buffer isn't big enough, it seems sysctl still returns 0 and just sets len to the
+ // necessary buffer size. This appears to be contrary to the man page, but it's easy to detect
+ // by simply checking len against the buffer length.
+ if (sysctl(name, 2, buf, len, IntPtr.Zero, 0) == 0 && *len < BUFFER_LENGTH)
+ {
+ return Marshal.PtrToStringAnsi((IntPtr)buf, (int)*len);
+ }
+ }
+ catch (Exception ex)
+ {
+ throw new PlatformNotSupportedException("Error reading Darwin Kernel Version", ex);
+ }
+ throw new PlatformNotSupportedException("Unknown error reading Darwin Kernel Version");
+ }
+
+ [DllImport("libc")]
+ private unsafe static extern int sysctl(
+ int* name,
+ uint namelen,
+ byte* oldp,
+ uint* oldlenp,
+ IntPtr newp,
+ uint newlen);
+ }
+ }
+
+ private class DistroInfo
+ {
+ public string Id;
+ public string VersionId;
+ }
+
+ private static readonly Lazy<Platform> _platform = new Lazy<Platform>(DetermineOSPlatform);
+ private static readonly Lazy<DistroInfo> _distroInfo = new Lazy<DistroInfo>(LoadDistroInfo);
+
+ public static string GetOSName()
+ {
+ switch (GetOSPlatform())
+ {
+ case Platform.Linux:
+ return GetDistroId() ?? "Linux";
+ case Platform.Darwin:
+ return "Mac OS X";
+ case Platform.FreeBSD:
+ return "FreeBSD";
+ default:
+ return "Unknown";
+ }
+ }
+
+ public static string GetOSVersion()
+ {
+ switch (GetOSPlatform())
+ {
+ case Platform.Linux:
+ return GetDistroVersionId() ?? string.Empty;
+ case Platform.Darwin:
+ return GetDarwinVersion() ?? string.Empty;
+ case Platform.FreeBSD:
+ return GetFreeBSDVersion() ?? string.Empty;
+ default:
+ return string.Empty;
+ }
+ }
+
+ private static string GetDarwinVersion()
+ {
+ Version version;
+ var kernelRelease = NativeMethods.Darwin.GetKernelRelease();
+ if (!Version.TryParse(kernelRelease, out version) || version.Major < 5)
+ {
+ // 10.0 covers all versions prior to Darwin 5
+ // Similarly, if the version is not a valid version number, but we have still detected that it is Darwin, we just assume
+ // it is OS X 10.0
+ return "10.0";
+ }
+ else
+ {
+ // Mac OS X 10.1 mapped to Darwin 5.x, and the mapping continues that way
+ // So just subtract 4 from the Darwin version.
+ // https://en.wikipedia.org/wiki/Darwin_%28operating_system%29
+ return $"10.{version.Major - 4}";
+ }
+ }
+
+ private static string GetFreeBSDVersion()
+ {
+ // This is same as sysctl kern.version
+ // FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC
+ // What we want is major release as minor releases should be compatible.
+ String version = RuntimeInformation.OSDescription;
+ try
+ {
+ // second token up to first dot
+ return RuntimeInformation.OSDescription.Split()[1].Split('.')[0];
+ }
+ catch
+ {
+ }
+ return string.Empty;
+ }
+
+ private static Platform GetOSPlatform()
+ {
+ return _platform.Value;
+ }
+
+ private static string GetDistroId()
+ {
+ return _distroInfo.Value?.Id;
+ }
+
+ private static string GetDistroVersionId()
+ {
+ return _distroInfo.Value?.VersionId;
+ }
+
+ private static DistroInfo LoadDistroInfo()
+ {
+ DistroInfo result = null;
+
+ // Sample os-release file:
+ // NAME="Ubuntu"
+ // VERSION = "14.04.3 LTS, Trusty Tahr"
+ // ID = ubuntu
+ // ID_LIKE = debian
+ // PRETTY_NAME = "Ubuntu 14.04.3 LTS"
+ // VERSION_ID = "14.04"
+ // HOME_URL = "http://www.ubuntu.com/"
+ // SUPPORT_URL = "http://help.ubuntu.com/"
+ // BUG_REPORT_URL = "http://bugs.launchpad.net/ubuntu/"
+ // We use ID and VERSION_ID
+
+ if (File.Exists("/etc/os-release"))
+ {
+ var lines = File.ReadAllLines("/etc/os-release");
+ result = new DistroInfo();
+ foreach (var line in lines)
+ {
+ if (line.StartsWith("ID=", StringComparison.Ordinal))
+ {
+ result.Id = line.Substring(3).Trim('"', '\'');
+ }
+ else if (line.StartsWith("VERSION_ID=", StringComparison.Ordinal))
+ {
+ result.VersionId = line.Substring(11).Trim('"', '\'');
+ }
+ }
+ }
+ else if (File.Exists("/etc/redhat-release"))
+ {
+ var lines = File.ReadAllLines("/etc/redhat-release");
+
+ if (lines.Length >= 1)
+ {
+ string line = lines[0];
+ if (line.StartsWith("Red Hat Enterprise Linux Server release 6.") ||
+ line.StartsWith("CentOS release 6."))
+ {
+ result = new DistroInfo();
+ result.Id = "rhel";
+ result.VersionId = "6";
+ }
+ }
+ }
+
+ if (result != null)
+ {
+ result = NormalizeDistroInfo(result);
+ }
+
+ return result;
+ }
+
+ // For some distros, we don't want to use the full version from VERSION_ID. One example is
+ // Red Hat Enterprise Linux, which includes a minor version in their VERSION_ID but minor
+ // versions are backwards compatable.
+ //
+ // In this case, we'll normalized RIDs like 'rhel.7.2' and 'rhel.7.3' to a generic
+ // 'rhel.7'. This brings RHEL in line with other distros like CentOS or Debian which
+ // don't put minor version numbers in their VERSION_ID fields because all minor versions
+ // are backwards compatible.
+ private static DistroInfo NormalizeDistroInfo(DistroInfo distroInfo)
+ {
+ // Handle if VersionId is null by just setting the index to -1.
+ int lastVersionNumberSeparatorIndex = distroInfo.VersionId?.IndexOf('.') ?? -1;
+
+ if (lastVersionNumberSeparatorIndex != -1 && distroInfo.Id == "alpine")
+ {
+ // For Alpine, the version reported has three components, so we need to find the second version separator
+ lastVersionNumberSeparatorIndex = distroInfo.VersionId.IndexOf('.', lastVersionNumberSeparatorIndex + 1);
+ }
+
+ if (lastVersionNumberSeparatorIndex != -1 && (distroInfo.Id == "rhel" || distroInfo.Id == "alpine"))
+ {
+ distroInfo.VersionId = distroInfo.VersionId.Substring(0, lastVersionNumberSeparatorIndex);
+ }
+
+ return distroInfo;
+ }
+
+ private static Platform DetermineOSPlatform()
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ return Platform.Linux;
+ }
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ return Platform.Darwin;
+ }
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD")))
+ {
+ return Platform.FreeBSD;
+ }
+
+ return Platform.Unknown;
+ }
+ }
+}
return nativeLib != IntPtr.Zero;
}
- public static Version OSXVersion { get; } = ToVersion(Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion);
+ public static Version OSXVersion { get; } = ToVersion(PlatformApis.GetOSVersion());
public static Version OpenSslVersion => !RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? GetOpenSslVersion() : throw new PlatformNotSupportedException();
return "OSX Version=" + s_osxProductVersion.ToString();
}
- DistroInfo v = GetDistroInfo();
+ var (name, version) = GetDistroInfo();
- return "Distro=" + v.Id + " VersionId=" + v.VersionId;
+ return "Distro=" + name + " VersionId=" + version;
}
/// <summary>
return new Version(int.Parse(versionString), 0);
}
- private static DistroInfo GetDistroInfo() => new DistroInfo()
- {
- Id = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystem,
- VersionId = ToVersion(Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.OperatingSystemVersion)
- };
+ private static (string name, Version version) GetDistroInfo() =>
+ (PlatformApis.GetOSName(), ToVersion(PlatformApis.GetOSVersion()));
private static bool IsRedHatFamilyAndVersion(int major = -1, int minor = -1, int build = -1, int revision = -1)
{
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- DistroInfo v = GetDistroInfo();
- if (distroPredicate(v.Id) && VersionEquivalentTo(major, minor, build, revision, v.VersionId))
+ var (name, version) = GetDistroInfo();
+ if (distroPredicate(name) && VersionEquivalentTo(major, minor, build, revision, version))
{
return true;
}
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
- DistroInfo v = GetDistroInfo();
- if (distroPredicate(v.Id) && VersionEquivalentToOrHigher(major, minor, build, revision, v.VersionId))
+ var (name, version) = GetDistroInfo();
+ if (distroPredicate(name) && VersionEquivalentToOrHigher(major, minor, build, revision, version))
{
return true;
}
private static extern int GlobalizationNative_GetICUVersion();
public static bool IsSuperUser => geteuid() == 0;
-
- private struct DistroInfo
- {
- public string Id { get; set; }
- public Version VersionId { get; set; }
- }
}
}
<Target Name="Build" DependsOnTargets="GenerateNativeVersionFile;BuildNativeUnix;BuildNativeWindows" />
<PropertyGroup>
+ <!-- Hardcode version paths in a global location. -->
+ <NativeVersionFile Condition="'$(OS)' == 'Windows_NT'">$(ArtifactsObjDir)_version.h</NativeVersionFile>
+ <NativeVersionFile Condition="'$(OS)' != 'Windows_NT'">$(ArtifactsObjDir)_version.c</NativeVersionFile>
<_BuildNativeArgs>$(ArchGroup) $(ConfigurationGroup) $(OSGroup) outconfig $(Configuration)</_BuildNativeArgs>
</PropertyGroup>
<Name>System.Diagnostics.FileVersionInfo.TestAssembly</Name>
</ProjectReference>
</ItemGroup>
- <Target Name="MangleTestAssemblyExtension" AfterTargets="PrepareForRun">
- <!-- Copy TestAssembly to file without .dll extension so that ILC preserves it as a data file rather than feeding it to the output executable. -->
- <Copy SourceFiles="$(TestPath)\System.Diagnostics.FileVersionInfo.TestAssembly.dll" DestinationFiles="$(TestPath)\System.Diagnostics.FileVersionInfo.TestAssembly.ildll" />
- </Target>
+ <ItemGroup>
+ <SupplementalTestData Include="$(OutputPath)System.Diagnostics.FileVersionInfo.TestAssembly.dll" DestinationName="System.Diagnostics.FileVersionInfo.TestAssembly.ildll" />
+ </ItemGroup>
</Project>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</ProjectReference>
</ItemGroup>
- <Target Name="RenameTestAssembly" AfterTargets="AfterBuild">
- <Move SourceFiles="$(TestPath)\System.Runtime.Loader.Noop.Assembly.dll" DestinationFiles="$(TestPath)\System.Runtime.Loader.Noop.Assembly_test.dll" />
+ <Target Name="RenameTestAssembly" AfterTargets="GetBinPlaceItems">
+ <ItemGroup>
+ <BinPlaceItem Remove="$(ArtifactsBinDir)**\System.Runtime.Loader.Noop.Assembly.dll" />
+ <SupplementalTestData Include="$(OutputPath)System.Runtime.Loader.Noop.Assembly_test.dll" />
+ </ItemGroup>
+ <Move SourceFiles="$(OutputPath)System.Runtime.Loader.Noop.Assembly.dll" DestinationFiles="$(OutputPath)System.Runtime.Loader.Noop.Assembly_test.dll" />
</Target>
</Project>
\ No newline at end of file
<Import Project="Directory.Build.props" />
<PropertyGroup>
- <BuildRestore Condition="'$(BuildRestore)' == ''">true</BuildRestore>
<BuildNative Condition="'$(BuildNative)' == ''">true</BuildNative>
<BuildManaged Condition="'$(BuildManaged)' == ''">true</BuildManaged>
- <BuildTests Condition="'$(BuildTests)' == ''">false</BuildTests>
<BuildPackages Condition="'$(BuildPackages)' == ''">true</BuildPackages>
- <BuildDependsOn Condition="'$(BuildRestore)' == 'true'">$(BuildDependsOn);Restore</BuildDependsOn>
<BuildDependsOn Condition="'$(BuildNative)' == 'true'">$(BuildDependsOn);BuildNative</BuildDependsOn>
<BuildDependsOn Condition="'$(BuildManaged)' == 'true'">$(BuildDependsOn);BuildManaged</BuildDependsOn>
- <BuildDependsOn Condition="'$(BuildTests)' == 'true'">$(BuildDependsOn);Test</BuildDependsOn>
<BuildDependsOn Condition="'$(BuildPackages)' == 'true'">$(BuildDependsOn);Pack</BuildDependsOn>
<!-- Explicitly set Configuration based on BuildConfiguration for the root projects -->
<MSBuild Projects="@(_BuildMangedProjects)" Properties="$(ProjectProperties)" />
</Target>
+ <Target Name="BuildTests">
+ <ItemGroup>
+ <_TestProjects Include="src\tests.builds" />
+ </ItemGroup>
+
+ <MSBuild Projects="@(_TestProjects)"
+ Targets="BuildAllProjects"
+ Properties="$(ProjectProperties);BuildTests=true" />
+ </Target>
+
<Target Name="Test">
<ItemGroup>
<_TestProjects Include="src\tests.builds" />
</ItemGroup>
- <MSBuild Projects="@(_TestProjects)" Properties="$(ProjectProperties)" />
+ <MSBuild Projects="@(_TestProjects)"
+ Targets="TestAllProjects"
+ Properties="$(ProjectProperties);Test=true" />
+ </Target>
+
+ <Target Name="IntegrationTest">
+ <ItemGroup>
+ <_TestProjects Include="src\tests.builds" />
+ </ItemGroup>
+
+ <MSBuild Projects="@(_TestProjects)"
+ Targets="TestAllProjects"
+ Properties="$(ProjectProperties);IntegrationTest=true" />
+ </Target>
+
+ <Target Name="PerformanceTest">
+ <ItemGroup>
+ <_TestProjects Include="src\tests.builds" />
+ </ItemGroup>
+
+ <MSBuild Projects="@(_TestProjects)"
+ Targets="TestAllProjects"
+ Properties="$(ProjectProperties);PerformanceTest=true" />
</Target>
<Target Name="Pack">
<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="Directory.Build.targets" />
+<Project>
+ <Import Project="Directory.Build.targets" />
<Target Name="ProducesPackageId"
Returns="@(PackageIds)"
</Target>
<Target Name="TestAllProjects"
- AfterTargets="BuildAllProjects"
- Condition="$(MSBuildProjectName.EndsWith('tests'))">
+ DependsOnTargets="$(TestAllProjectsDependsOn)">
+
+ <PropertyGroup>
+ <TestAllTarget Condition="'$(IntegrationTest)' == 'true'">IntegrationTest</TestAllTarget>
+ <TestAllTarget Condition="'$(PerformanceTest)' == 'true'">PerformanceTest</TestAllTarget>
+ <TestAllTarget Condition="'$(Test)' == 'true'">Test</TestAllTarget>
+ </PropertyGroup>
<!-- To Serialize we use msbuild's batching functionality '%' to force it to batch all similar projects with the same identity
however since the project names are unique it will essentially force each to run in its own batch -->
- <MSBuild Targets="Test"
+ <MSBuild Targets="$(TestAllTarget)"
Projects="@(Project)"
Condition="'$(SerializeProjects)'=='true' AND '%(Identity)' != ''"
Properties="DefaultBuildAllTarget=$(DefaultBuildAllTarget);BuildAllProjects=true;BuildConfiguration=$(BuildConfiguration)"
ContinueOnError="ErrorAndContinue" />
- <MSBuild Targets="Test"
+ <MSBuild Targets="$(TestAllTarget)"
Projects="@(Project)"
Condition="'$(SerializeProjects)'!='true'"
Properties="DefaultBuildAllTarget=$(DefaultBuildAllTarget);BuildAllProjects=true;BuildConfiguration=$(BuildConfiguration)"
CleanAllProjects;
$(TraversalCleanDependsOn);
</TraversalCleanDependsOn>
+
+ <TestAllProjectsDependsOn Condition="'$(BuildTests)' == 'true'">
+ BuildAllProjects;
+ $(TestAllProjectsDependsOn);
+ </TestAllProjectsDependsOn>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="$(TraversalBuildDependsOn)" />
<!-- for callstack line numbers -->
<PackageReference Include="Microsoft.DiaSymReader.Native" Version="1.5.0" />
- <PackageReference Condition="'$(TargetGroup)' != 'uapaot'" Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<!-- Test Data -->
<PackageToInclude Condition="'$(TargetsUap)' != 'true'" Include="$(XUnitRunnerConsolePackageName)" />
<PackageToInclude Include="Microsoft.DiaSymReader.Native" />
<PackageToInclude Include="Newtonsoft.Json" />
- <PackageToInclude Condition="'$(TargetGroup)' != 'uapaot'" Include="Microsoft.DotNet.PlatformAbstractions" />
</ItemGroup>
<!-- Perf testing -->
</Target>
<!-- System.Data.SqlClient tests require sni.dll in the test folder -->
- <ItemGroup Condition="'$(TargetsAot)'=='true'">
+ <ItemGroup Condition="'$(TargetsAot)' == 'true'">
<PackageReference Include="runtime.native.System.Data.SqlClient.sni" Version="$(RuntimeWinX64RuntimeNativeSystemDataSqlClientSniPackageVersion)" />
<PackageToInclude Include="runtime.win-arm64.runtime.native.System.Data.SqlClient.sni"/>
AfterTargets="AfterResolveReferences">
<PropertyGroup>
-
<UAPToolsFolder Condition="'$(UAPToolsFolder)'==''">$(PackagesDir)$(MicrosoftDotNetUapTestToolsPackageName)\$(MicrosoftDotNetUapTestToolsPackageVersion)\Tools\$(ArchGroup)</UAPToolsFolder>
<UAPToolsFolder>$(UAPToolsFolder.Replace('/', '\'))</UAPToolsFolder>
</PropertyGroup>
<!-- Give a warning that the UAPToolsFolder is not set and that tests won't run -->
- <Warning Condition="('$(UAPToolsFolder)'=='' or !Exists('$(UAPToolsFolder)')) AND '$(BuildAllConfigurations)' != 'true'" Text="Could not find the UAP Tools at '$(UAPToolsFolder)'. Please run sync." />
+ <Warning Condition="('$(UAPToolsFolder)'=='' or !Exists('$(UAPToolsFolder)')) AND '$(BuildAllConfigurations)' != 'true'" Text="Could not find the UAP Tools at '$(UAPToolsFolder)'. Please run restore." />
<ItemGroup Condition="'$(UAPToolsFolder)'!=''">
<RunnerFolderContents Include="$(UAPToolsFolder)\Runner\**\*" />
<TestILCFolder Condition="'$(TestILCFolder)' == ''">$(PackagesDir)$(TestILCToolsPackageName)\$(ProjectNTfsTestILCPackageVersion)\TestILC</TestILCFolder>
</PropertyGroup>
- <Warning Condition="('$(TestILCFolder)' == '' OR !Exists('$(TestILCFolder)')) AND '$(BuildAllConfigurations)' != 'true'" Text="Could not find the TestILC Tools at '$(TestILCFolder)'. Please run sync." />
-
<ItemGroup Condition="Exists('$(TestILCFolder)')">
<TestILCFolderContents Include="$(TestILCFolder)\**\*" />
</ItemGroup>
<Target Name="ArchiveHelixItems"
DependsOnTargets="GenerateProjects;CopyProducedPackages"
- Condition="'$(ArchiveTests)' == 'true'">
+ Condition="'$(ArchiveTests.ToLower())' == 'packages' or '$(ArchiveTests.ToLower())' == 'all'">
<MakeDir Directories="$(TestArchiveTestsRoot)" />
<ZipDirectory
<Target Name="RestoreProjects"
DependsOnTargets="GenerateProjects"
- Condition="'$(ArchiveTests)' != 'true'">
+ Condition="'$(ArchiveTests.ToLower())' != 'packages' and '$(ArchiveTests.ToLower())' != 'all'">
<PropertyGroup>
<TestRestoreCommand>$(TestDotNetPath)</TestRestoreCommand>
<Target Name="BuildProjects"
DependsOnTargets="RestoreProjects"
- Condition="'$(ArchiveTests)' != 'true'">
+ Condition="'$(ArchiveTests.ToLower())' != 'packages' and '$(ArchiveTests.ToLower())' != 'all'">
<PropertyGroup>
<TestBuildCommand>$(TestDotNetPath)</TestBuildCommand>
<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.props))\Directory.Build.props" />
+<Project DefaultTargets="Build">
+ <Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" />
<PropertyGroup>
<!-- When building through build-tests.cmd tests.builds is the main project that is being built. We set IsTestProject to true when the project path has /tests/.
Since IsTestProject is set to false in this case, when TargetGroup = netfx it will add net462 and net47 build configurations if they exist on the test project.
We only want to build tests against current TargetGroup -->
<AdditionalBuildConfigurations Condition="'$(TargetGroup)' == 'netfx'"></AdditionalBuildConfigurations>
- <EnableBenchviewTarget>true</EnableBenchviewTarget>
+ <EnableBenchviewTarget Condition="'$(PerformanceTest)' == 'true'">true</EnableBenchviewTarget>
<EnableFullCoverageReportTarget>true</EnableFullCoverageReportTarget>
<GenerateFullCoverageReport>true</GenerateFullCoverageReport>
<CoverageReportInputPath>$(TestWorkingDir)**/coverage.xml</CoverageReportInputPath>
<CoverageReportDir>$(ArtifactsDir)coverage</CoverageReportDir>
+ <!-- For UAP we are using an APPX that is registered with a unique ID. Because of that we need to run tests sequentially -->
+ <SerializeProjects Condition="'$(BuildTests)' != 'true' AND ('$(BuildingUAPVertical)' == 'true' or '$(Coverage)' == 'true' or '$(PerformanceTest)' == 'true')">true</SerializeProjects>
+ <TraversalBuildDependsOn Condition="'$(BuildingUAPVertical)' == 'true'">MakeCommonResourcesPriFile;$(TraversalBuildDependsOn)</TraversalBuildDependsOn>
</PropertyGroup>
- <ItemGroup Condition="'$(RunningSharedFrameworkValidation)'=='true'">
+ <ItemGroup Condition="'$(RunningSharedFrameworkValidation)' == 'true'">
<TestProjectExclusions Include="$(MSBuildThisFileDirectory)*\tests\**\System.Data.Odbc.Tests.csproj" />
<TestProjectExclusions Include="$(MSBuildThisFileDirectory)*\tests\**\System.IO.Pipes.Tests.csproj" />
<TestProjectExclusions Include="$(MSBuildThisFileDirectory)*\tests\**\Microsoft.XmlSerializer.Generator.Tests.csproj" />
<TestProjectExclusions Include="$(MSBuildThisFileDirectory)*\tests\**\System.Reflection.Context.Tests.csproj" />
</ItemGroup>
- <!-- For UAP we are using an APPX that is registered with a unique ID. Because of that we need to run tests sequentially -->
- <PropertyGroup Condition="('$(BuildingUAPVertical)'=='true' OR '$(Coverage)' == 'true') AND '$(SkipTests)' != 'true'">
- <SerializeProjects>true</SerializeProjects>
- </PropertyGroup>
-
- <Target Name="BinPlaceXUnitRuntimeForNetstandardSuite" Condition="'$(TargetGroup)' == 'netstandard'" BeforeTargets="BuildAllProjects">
- <!-- Ensure that we binplace all of the xunit assemblies on the netstandard runtime path in order to be able to build netstandard test suite -->
- <MSBuild Projects="$(MSBuildThisFileDirectory)../external/test-runtime/XUnit.Runtime.depproj"
- Properties="TargetGroup=$(TargetGroup)"
- RemoveProperties="Configuration"
- ContinueOnError="ErrorAndStop" />
- </Target>
-
<PropertyGroup>
- <_ProjectPattern Condition="'$(Performance)' != 'true'">Tests</_ProjectPattern>
- <_ProjectPattern Condition="'$(Performance)' == 'true'">PerformanceTests</_ProjectPattern>
+ <TestProjectFilter Condition="'$(Test)' == 'true'">Tests</TestProjectFilter>
+ <TestProjectFilter Condition="'$(IntegrationTest)' == 'true'">IntegrationTests</TestProjectFilter>
+ <TestProjectFilter Condition="'$(PerformanceTest)' == 'true'">PerformanceTests</TestProjectFilter>
+
+ <_TestProjectFilter Condition="'$(TestProjectFilter)' != ''">.$(TestProjectFilter)</_TestProjectFilter>
+ <!-- By default build all test project types to capture build errors in CI. -->
+ <_TestProjectFilter Condition="'$(TestProjectFilter)' == '' or '$(BuildAllTests)' == 'true'">Tests</_TestProjectFilter>
</PropertyGroup>
<ItemGroup Condition="'$(BuildAllConfigurations)' != 'true'">
<!-- Keep in sync with pattern for test projects in build.proj -->
- <Project Include="$(MSBuildThisFileDirectory)*\tests\**\*$(_ProjectPattern).csproj" Exclude="@(TestProjectExclusions)" />
- <Project Include="$(MSBuildThisFileDirectory)*\tests\**\*$(_ProjectPattern).vbproj" Exclude="@(TestProjectExclusions)" />
+ <Project Include="$(MSBuildThisFileDirectory)*\tests\**\*$(_TestProjectFilter).csproj" Exclude="@(TestProjectExclusions)" />
+ <Project Include="$(MSBuildThisFileDirectory)*\tests\**\*$(_TestProjectFilter).vbproj" Exclude="@(TestProjectExclusions)" />
</ItemGroup>
<ItemGroup Condition="'$(BuildAllConfigurations)' == 'true'">
<Project Include="$(ProjectDir)pkg\test\testPackages.proj" />
</ItemGroup>
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.traversal.targets))\dir.traversal.targets" />
+ <Target Name="BinPlaceXUnitRuntimeForNetstandardSuite"
+ Condition="'$(TargetGroup)' == 'netstandard'"
+ BeforeTargets="BuildAllProjects">
+ <!-- Ensure that we binplace all of the xunit assemblies on the netstandard runtime path in order to be able to build netstandard test suite -->
+ <MSBuild Projects="$(MSBuildThisFileDirectory)../external/test-runtime/XUnit.Runtime.depproj"
+ Properties="TargetGroup=$(TargetGroup)"
+ RemoveProperties="Configuration"
+ ContinueOnError="ErrorAndStop" />
+ </Target>
- <PropertyGroup Condition="'$(BuildingUAPVertical)' == 'true'">
- <TraversalBuildDependsOn>
- MakeCommonResourcesPriFile;
- $(TraversalBuildDependsOn)
- </TraversalBuildDependsOn>
- </PropertyGroup>
+ <Import Project="$([MSBuild]::GetPathOfFileAbove(dir.traversal.targets))" />
</Project>