dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

Microsoft.Build.Runtime 15.1.548 needs an explicit reference to "System.Collections.Immutable" #1869

Closed mishra14 closed 7 years ago

mishra14 commented 7 years ago

It seems that Microsoft.Build.Runtime needs an explicit reference to "System.Collections.Immutable" Version="1.2.1".

Project -

<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'common.test.props'))\common.test.props" />
  <PropertyGroup>
    <TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks>
    <TargetFrameworks Condition=" '$(IsXPlat)' == 'true' ">netcoreapp1.0</TargetFrameworks>
    <TestProject>true</TestProject>
    <TestProjectType>functional</TestProjectType>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Build.Runtime" Version="15.1.548" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\..\..\src\NuGet.Core\NuGet.CommandLine.XPlat\NuGet.CommandLine.XPlat.csproj" />
    <ProjectReference Include="..\..\..\src\NuGet.Core\NuGet.Test.Utility\NuGet.Test.Utility.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
  </ItemGroup>
  <ItemGroup>
    <None Update="xunit.runner.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
  <Import Project="$(BuildCommonDirectory)common.targets" />
</Project>

Error -

Error Message:
 System.AggregateException : One or more errors occurred.
---- System.IO.FileNotFoundException : Could not load file or assembly 'System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack Trace:
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at NuGet.XPlat.FuncTest.XPlatAddPkgTests.<AddPkg_UnconditionalAdd_Success>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)
----- Inner Stack Trace -----
   at Microsoft.Build.Evaluation.LazyItemEvaluator`4.ProcessItemElement(String rootDirectory, ProjectItemElement itemElement, Boolean conditionResult)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateItemElement(Boolean itemGroupConditionResult, ProjectItemElement itemElement, LazyItemEvaluator`4 lazyEvaluator)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateItemGroupElement(ProjectItemGroupElement itemGroupElement, LazyItemEvaluator`4 lazyEvaluator)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCache projectRootElementCache, BuildEventContext buildEventContext, ProjectInstance projectInstanceIfAnyForDebuggerOnly)
   at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(ProjectRootElement xml, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings)
   at Microsoft.Build.Evaluation.Project..ctor(ProjectRootElement xml)
   at NuGet.CommandLine.XPlat.MSBuildAPIUtility.GetProject(String projectCSProjPath) in E:\migrate\NuGet.Client\src\NuGet.Core\NuGet.CommandLine.XPlat\Utility\MSBuildAPIUtility.cs:line 49
   at NuGet.CommandLine.XPlat.MSBuildAPIUtility.AddPackageReference(String projectPath, PackageDependency packageDependency) in E:\migrate\NuGet.Client\src\NuGet.Core\NuGet.CommandLine.XPlat\Utility\MSBuildAPIUtility.cs:line 113
   at NuGet.CommandLine.XPlat.AddPackageReferenceCommandRunner.<ExecuteCommand>d__0.MoveNext() in E:\migrate\NuGet.Client\src\NuGet.Core\NuGet.CommandLine.XPlat\Commands\PackageReferenceCommands\AddPackageReferenceCommandRunner.cs:line 108

Workaround -

Goes away by adding a reference to System.Collections.Immuatble v1.2.1

dotnet add package system.collections.immutable -v 1.2.1

mishra14 commented 7 years ago

@rainersigwald

rainersigwald commented 7 years ago

Not sure if we just have to update the Immutable ref in Tasks.Core from 1.2.0 (introduced in #1682), or if we should add a direct ref somewhere else. @jeffkl thoughts?

cdmihai commented 7 years ago

@mishra14 can you please retry this with the latest dotnet.myget.org package: 15.2.0-preview-000069-02

The msbuild package you referenced is from February, and might not include our fix for immutable.

AndyGerlicher commented 7 years ago

This is fixed post RTW. Our "preview" packages declare this reference and will be published to NuGet with a future Visual Studio update.