diff options
-rw-r--r-- | tests/build.proj | 32 | ||||
-rw-r--r-- | tests/dir.props | 24 | ||||
-rw-r--r-- | tests/publishdependency.targets | 2 | ||||
-rw-r--r-- | tests/runtest.proj | 29 | ||||
-rw-r--r-- | tests/src/Common/test_runtime/test_runtime.csproj | 2 | ||||
-rw-r--r-- | tests/src/NuGet.Config | 2 |
6 files changed, 81 insertions, 10 deletions
diff --git a/tests/build.proj b/tests/build.proj index ca3896d2ea..70029f19e3 100644 --- a/tests/build.proj +++ b/tests/build.proj @@ -12,6 +12,7 @@ <PropertyGroup> <TraversalBuildDependsOn> + ValidateAllProjectDependencies; BatchRestorePackages; $(TraversalBuildDependsOn); </TraversalBuildDependsOn> @@ -22,13 +23,38 @@ <!-- restore all project.jsons in one pass for perf & to avoid concurrency problems --> <Exec Command="$(DnuRestoreCommand) $(DnuRestoreDirs)" - StandardOutputImportance="Low" - CustomErrorRegularExpression="^Unable to locate .*" - ContinueOnError="WarnAndContinue" /> + StandardOutputImportance="Low" /> <Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages...Done." /> </Target> + <!-- Task from buildtools that validates dependencies contained in project.json files. --> + <UsingTask TaskName="ValidateProjectDependencyVersions" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" /> + + <Target Name="ValidateAllProjectDependencies" + Condition="'$(ValidatePackageVersions)'=='true' and '@(ProjectJsonFiles)'!=''"> + <ValidateProjectDependencyVersions ProjectJsons="@(ProjectJsonFiles)" + ProhibitFloatingDependencies="$(ProhibitFloatingDependencies)" + ValidationPatterns="@(ValidationPattern)" /> + </Target> + + <Target Name="UpdateInvalidPackageVersions"> + <ValidateProjectDependencyVersions ProjectJsons="@(ProjectJsonFiles)" + ProhibitFloatingDependencies="$(ProhibitFloatingDependencies)" + ValidationPatterns="@(ValidationPattern)" + UpdateInvalidDependencies="true" /> + </Target> + + <!-- Tasks from buildtools for easy project.json dependency updates --> + <UsingTask TaskName="UpdatePackageDependencyVersion" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" /> + + <Target Name="UpdatePackageDependencyVersion"> + <UpdatePackageDependencyVersion ProjectJsons="@(ProjectJsonFiles)" + PackageId="$(PackageId)" + OldVersion="$(OldVersion)" + NewVersion="$(NewVersion)" /> + </Target> + <!-- Override RestorePackages from dir.traversal.targets and do a batch restore --> <Target Name="RestorePackages" DependsOnTargets="BatchRestorePackages" /> </Project> diff --git a/tests/dir.props b/tests/dir.props index d0f3e35e1d..5fa0916776 100644 --- a/tests/dir.props +++ b/tests/dir.props @@ -32,6 +32,21 @@ <BuildToolsTaskDir Condition="'$(BuildToolsTargets45)' == 'true'">$(ToolsDir)net45/</BuildToolsTaskDir> </PropertyGroup> + <!-- Package dependency validation --> + <PropertyGroup> + <ValidatePackageVersions>true</ValidatePackageVersions> + <ProhibitFloatingDependencies>true</ProhibitFloatingDependencies> + </PropertyGroup> + + <ItemGroup> + <ValidationPattern Include="^(?i)((System\..%2A)|(Microsoft\.CSharp)|(Microsoft\.NETCore.%2A)|(Microsoft\.Win32\..%2A)|(Microsoft\.VisualBasic))(?<!TestData)$"> + <ExpectedPrerelease>rc2-23816</ExpectedPrerelease> + </ValidationPattern> + <ValidationPattern Include="^(?i)xunit\..%2A$"> + <ExpectedVersion>2.1.0</ExpectedVersion> + </ValidationPattern> + </ItemGroup> + <!-- Common nuget properties --> <PropertyGroup> <NuGetToolPath Condition="'$(NuGetToolPath)'==''">$(PackagesDir)NuGet.exe</NuGetToolPath> @@ -81,7 +96,14 @@ <DnuRestoreCommand>$(DnuRestoreCommand) restore</DnuRestoreCommand> <DnuRestoreCommand>$(DnuRestoreCommand) --packages "$(PackagesDir.TrimEnd('/\'.ToCharArray()))" $(DnuRestoreSource)</DnuRestoreCommand> </PropertyGroup> - + + <!-- Create a collection of all project.json files for dependency updates. --> + <ItemGroup> + <!-- Skip validation of the test_runtime project created by the test build. --> + <ProjectJsonFiles Include="$(SourceDir)**/project.json" + Exclude="$(SourceDir)Common\test_runtime\project.json" /> + </ItemGroup> + <!-- Which tests shall we build? Default: Priority 0 tests. At the command-line, the user can specify /p:CLRTestPriorityToBuild=666 (for example), and all tests with CLRTestPriority 666,..., 1 AND 0 will build. diff --git a/tests/publishdependency.targets b/tests/publishdependency.targets index dcda2cf089..a5aa7f13ff 100644 --- a/tests/publishdependency.targets +++ b/tests/publishdependency.targets @@ -32,7 +32,7 @@ <PrereleaseResolveNuGetPackageAssets AllowFallbackOnTargetSelection="true" IncludeFrameworkReferences="false" NuGetPackagesDirectory="$(PackagesDir)" - RuntimeIdentifier="dotnet" + RuntimeIdentifier="$(TestNugetRuntimeId)" ProjectLanguage="$(Language)" ProjectLockFile="%(ProjectLockJsonFiles.Identity)" TargetMonikers="@(TestTargetFramework)"> diff --git a/tests/runtest.proj b/tests/runtest.proj index f882a466ea..4c9a6467e6 100644 --- a/tests/runtest.proj +++ b/tests/runtest.proj @@ -128,7 +128,6 @@ $(_XunitEpilog) "xunit" : "2.1.0", "xunit.assert" : "2.1.0", "xunit.core" : "2.1.0", - "xunit.runner.msbuild": "2.1.0" }, "frameworks": { "net45": { @@ -304,11 +303,33 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). <MSBuild Projects="$(MSBuildProjectFile)" Targets="CreateXunitWrapper" Properties="_CMDDIR=%(TestDirectories.Identity)" /> <Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages..." /> + + <!-- + Contents of a project.json that will be restored once with errors turned off. This works + around the package being incompatible with dotnet restore. Only the package contents are + required so the compatibility errors can be ignored. + --> + <PropertyGroup> + <XunitRunnerRestoreGenConfig>{ "dependencies": { "xunit.runner.msbuild": "2.1.0" }, "frameworks": { "net45": {} } }</XunitRunnerRestoreGenConfig> + <XunitRunnerRestoreProjectDir>$(BaseOutputPath)\tempRestoreProject</XunitRunnerRestoreProjectDir> + <XunitRunnerRestoreProjectJsonPath>$(XunitRunnerRestoreProjectDir)\project.json</XunitRunnerRestoreProjectJsonPath> + </PropertyGroup> + + <MakeDir Directories="$(XunitRunnerRestoreProjectDir)" /> + <WriteLinesToFile File="$(XunitRunnerRestoreProjectJsonPath)" + Lines="$(XunitRunnerRestoreGenConfig)" + Overwrite="true" /> + + <Exec Command="$(DnuRestoreCommand) "$(XunitRunnerRestoreProjectJsonPath)"" + StandardOutputImportance="Low" + CustomErrorRegularExpression="^Unable to resolve .*" + IgnoreExitCode="true" + IgnoreStandardErrorWarningFormat="true" /> + <!-- Restore all wrapper projects' project.jsons in one pass for perf & to avoid concurrency problems --> <Exec Command="$(DnuRestoreCommand) "$(XunitWrapperGeneratedCSDirBase.TrimEnd('\\'))"" - StandardOutputImportance="Low" - CustomErrorRegularExpression="^Unable to locate .*" - ContinueOnError="WarnAndContinue" /> + StandardOutputImportance="Low" /> + <Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages...Done." /> <MSBuild Projects="$(MSBuildProjectFile)" Targets="BuildXunitWrapper" Properties="_CMDDIR=%(TestDirectories.Identity)" /> diff --git a/tests/src/Common/test_runtime/test_runtime.csproj b/tests/src/Common/test_runtime/test_runtime.csproj index e9e3a5a911..5b89f40d19 100644 --- a/tests/src/Common/test_runtime/test_runtime.csproj +++ b/tests/src/Common/test_runtime/test_runtime.csproj @@ -7,6 +7,8 @@ <OutputType>Library</OutputType> <GenerateRunScript>false</GenerateRunScript> <CLRTestKind>BuildOnly</CLRTestKind> + <!-- Skip validation of the test_runtime project created by the test build. --> + <ValidatePackageVersions>false</ValidatePackageVersions> </PropertyGroup> <ItemGroup> <DnuSourceList Include="$(CORE_ROOT)\.nuget\pkg" /> diff --git a/tests/src/NuGet.Config b/tests/src/NuGet.Config index 081afc6363..51701f05f6 100644 --- a/tests/src/NuGet.Config +++ b/tests/src/NuGet.Config @@ -7,7 +7,7 @@ <clear/> <add key="myget.org dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> <add key="myget.org nugetbuild" value="https://www.myget.org/F/nugetbuild/api/v3/index.json" /> - <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> + <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> </packageSources> <activePackageSource> <add key="All" value="(Aggregate source)" /> |