Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Build managed projects and tests with csproj's #2259

Merged
merged 20 commits into from
May 4, 2017

Conversation

mellinoe
Copy link

@mellinoe mellinoe commented May 2, 2017

  • Replace all test projects and test assets with csproj files.
    • Update some test code to use only properties that the 2.0 CLI understands.
    • Pass through additional properties in the test code in order to restore and build projects for the correct RID and version of Microsoft.NETCore.App (Fixes https://github.com/dotnet/core-setup/issues/2127)
  • Replace src/managed/*project.json with csproj files.
    • Update GetBuildArgsByFrameworks so it understands how to read and parse csproj files instead of project.json files.
  • Update dir.proj's to correctly restore and build the csproj files (using DotnetSdkToolCommand instead of DotnetToolCommand).

@eerhardt @weshaggard

@mellinoe
Copy link
Author

mellinoe commented May 3, 2017

I pushed a couple of commits which should fix some Linux problems. I'm going to need some help understanding the remaining test issues -- they don't make a lot of sense to me.

<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">

This comment was marked as spam.

This comment was marked as spam.

@@ -24,7 +24,7 @@
<Output ItemName="buildCmdArgs" TaskParameter="BuildArgs" />
</GetBuildArgsByFrameworks>

<Exec Command="$(DotnetToolCommand) build $(Args) %(buildCmdArgs.Identity)"
<Exec Command="$(DotnetSdkToolCommand) build $(Args) %(buildCmdArgs.Identity)"

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -160,18 +160,19 @@

<Target Name="GenerateNugetPackages" DependsOnTargets="InitPackage">
<ItemGroup>
<PackageProjects Include="$(ProjectDir)src\managed\Microsoft.DotNet.PlatformAbstractions\project.json" />
<PackageProjects Include="$(ProjectDir)src\managed\Microsoft.Extensions.DependencyModel\project.json" />
<PackageProjects Condition="'$(OS)' == 'Windows'" Include="$(ProjectDir)src\managed\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

<RuntimeFrameworkVersion>$(MNAVersion)</RuntimeFrameworkVersion>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">

This comment was marked as spam.

This comment was marked as spam.


string baseArtifactsFolder = artifacts ?? Path.Combine(_repoRoot, "Bin");

_targetRID = Environment.GetEnvironmentVariable("TEST_TARGETRID");
_buildRID = Environment.GetEnvironmentVariable("BUILDRID");
_mnaVersion = Environment.GetEnvironmentVariable("MNA_VERSION");

This comment was marked as spam.

if ( ! _testProject.IsRestored())
{
RestoreProject(fallbackSources);
string extraMSBuildProperties = $"/p:RuntimeIdentifiers={rid} /p:RuntimeIdentifier={rid}";

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

EnvironmentVariables="NUGET_PACKAGES=$(PackagesDir);TEST_ARTIFACTS=$(SystemPathTestsOutputDir);TEST_TARGETRID=$(TestTargetRid);BUILDRID=$(TargetRid)"
<Exec Command="$(DotnetTestToolCommand) test $(TestArgs) --logger &quot;trx;LogFileName=$(TestResultsXml)&quot;"
WorkingDirectory="$(TestWorkingDirectory)"
EnvironmentVariables="NUGET_PACKAGES=$(PackagesDir);TEST_ARTIFACTS=$(SystemPathTestsOutputDir);TEST_TARGETRID=$(TestTargetRid);BUILDRID=$(TargetRid);MNA_VERSION=$(ProductVersion)"

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@mellinoe
Copy link
Author

mellinoe commented May 3, 2017

With the two latest commits, I have a clean build on my Ubuntu machine. Hopefully we will see some green in CI now.

@@ -50,6 +50,12 @@ public void Running_Build_Output_Standalone_EXE_with_DepsJson_and_RuntimeConfig_

var appExe = fixture.TestProject.AppExe;

// TODO: Use FS.Chmod when build utility project is converted to csproj.

This comment was marked as spam.

This comment was marked as spam.

@@ -17,7 +17,8 @@ public class PackageResolverTest
{
private static string PackagesPath = Path.Combine("package", "directory", "location");

[Fact]
// This test does not work on .NET Core 2.0.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -31,21 +32,20 @@ public override bool Execute()
List<string> args = new List<string>();
foreach (var projectJsonPath in ProjectJsonPaths)
{
using (TextReader projectFileReader = File.OpenText(projectJsonPath.ItemSpec))
string dir = Path.GetDirectoryName(projectJsonPath.ItemSpec);

This comment was marked as spam.

This comment was marked as spam.

@mellinoe
Copy link
Author

mellinoe commented May 3, 2017

I think we will need to modify the netci.groovy script, because we are not producing xunit test results anymore. Rather, we are producing "TRX" logs.

EDIT: I've made that change, but the CI jobs will still all show failures because of this.

@weshaggard
Copy link
Member

I"m good with merging this if you have confirmed it works and follow-up after your netci changes are in to ensure everything is green.

@mellinoe
Copy link
Author

mellinoe commented May 3, 2017

The only thing I need to fix is the x86 run. I think I understand why it failed, though.

<VersionPrefix>2.0.0</VersionPrefix>
<TargetFrameworks>net451;netstandard1.3;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AssemblyName>Microsoft.Extensions.DependencyModel</AssemblyName>

This comment was marked as spam.

<PackageId>Microsoft.Extensions.DependencyModel</PackageId>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>git://github.com/dotnet/core-setup</RepositoryUrl>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'netstandard1.6' ">$(PackageTargetFallback);portable-net45+wp80+win8+wpa81+dnxcore50</PackageTargetFallback>

This comment was marked as spam.

</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />

This comment was marked as spam.

@eerhardt
Copy link
Member

eerhardt commented May 3, 2017

  ProjectJsonPaths="@(PackageProjects)">

Should rename ProjectJsonPaths


Refers to: src/managed/dir.proj:23 in bd5f1ce. [](commit_id = bd5f1ce, deletion_comment = False)

</ItemGroup>

<PropertyGroup>
<BuildBasePathArg>--build-base-path $(IntermediateOutputForPackaging)</BuildBasePathArg>
<BuildBasePathArg></BuildBasePathArg>

This comment was marked as spam.


<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>LightupClient</AssemblyName>

This comment was marked as spam.

restoreArgs.Add(fallbackSource);
}
restoreArgs.Add("--disable-parallel");

restoreArgs.Add($"/p:MNAVersion={_repoDirectoriesProvider.MicrosoftNETCoreAppVersion}");

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

if ( ! _testProject.IsRestored())
{
RestoreProject(fallbackSources);
string extraMSBuildProperties = $"/p:TestTargetRid={rid}";

This comment was marked as spam.

This comment was marked as spam.

<AssemblyName>PortableTestApp</AssemblyName>
<PackageId>PortableTestApp</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>

This comment was marked as spam.

<AssemblyName>StandaloneApp</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>StandaloneApp</PackageId>
<RuntimeIdentifiers>$(TestTargetRid)</RuntimeIdentifiers>

This comment was marked as spam.

<PackageId>StandaloneTestApp</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
<RuntimeIdentifiers>$(TestTargetRid)</RuntimeIdentifiers>

This comment was marked as spam.

@@ -1 +1 @@
1.0.0-preview3-003886
2.0.0-preview1-005899

This comment was marked as spam.

This comment was marked as spam.

@@ -96,7 +96,7 @@ private void ComputeSharedFxPaths()
GreatestVersionSharedFxPath = sharedFxVersionDirectories
.OrderByDescending(p => p.ToLower())
.First();

This comment was marked as spam.

// TODO: Use FS.Chmod when build utility project is converted to csproj.
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Command.Create("chmod", "+x", appExe).Execute().EnsureSuccessful();

This comment was marked as spam.

<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>HostActivationTests</AssemblyName>
<PackageId>HostActivationTests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

<ProjectReference Include="..\..\managed\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />
<ProjectReference Include="..\..\managed\Microsoft.Extensions.DependencyModel\Microsoft.Extensions.DependencyModel.csproj" />

<!-- TODO: Should this dependency be removed? -->

This comment was marked as spam.

This comment was marked as spam.

@@ -50,8 +50,8 @@ public class TestProject
_sharedLibraryExtension = sharedLibraryExtension;
_sharedLibraryPrefix = sharedLibraryPrefix;
_projectName = Path.GetFileName(_projectDirectory);
_projectJson = Path.Combine(_projectDirectory, "project.json");
_projectLockJson = Path.Combine(_projectDirectory, "project.lock.json");
_projectJson = Path.Combine(_projectDirectory, $"{_projectName}.csproj");

This comment was marked as spam.


<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

This comment was marked as spam.

netci.groovy Outdated
@@ -84,7 +84,7 @@ platformList.each { platform ->
Utilities.standardJobSetup(newJob, project, isPR, "*/${branch}")

if (!(os == 'Windows_NT' && architecture == 'arm')) {
Utilities.addXUnitDotNETResults(newJob, '**/*-testResults.xml')
Utilities.addMSTestResults(newJob, '**/*-testResults.xml')

This comment was marked as spam.

{
Console.WriteLine("OSGroup: " + OSGroup);

This comment was marked as spam.

This comment was marked as spam.

@@ -31,21 +32,20 @@ public override bool Execute()
List<string> args = new List<string>();
foreach (var projectJsonPath in ProjectJsonPaths)
{
using (TextReader projectFileReader = File.OpenText(projectJsonPath.ItemSpec))
string dir = Path.GetDirectoryName(projectJsonPath.ItemSpec);

This comment was marked as spam.

{
args.Add($"--framework {framework.Name} {dir}");
args.Add($"--framework {framework} {projectJsonPath}");

This comment was marked as spam.

@mellinoe
Copy link
Author

mellinoe commented May 4, 2017

@dotnet-bot Test Windows_NT x64 Release Build

@mellinoe
Copy link
Author

mellinoe commented May 4, 2017

I think this is at an okay state to go in now. All of the CI "failures" are because of the mismatched test results files, and shouldn't show up after the update to netci.groovy gets consumed.

@mellinoe mellinoe merged commit 3c952f2 into dotnet:master May 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants