Skip to content

Building Microsoft.Extensions.DependencyInjection.Abstractions fails in VS #67091

Closed

Description

@Linlccc
4>------ 已启动全部重新生成: 项目: Microsoft.Extensions.DependencyInjection.Abstractions (src\Microsoft.Extensions.DependencyInjection.Abstractions), 配置: Debug Any CPU ------
4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\net6.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\netstandard2.1\Microsoft.Extensions.DependencyInjection.Abstractions.dll
4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018: “GenerateDepsFile”任务意外失败。
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018: System.NullReferenceException: 未将对象引用设置到对象的实例。
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.ReferenceInfo.GetVersion(ITaskItem referencePath)
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.ReferenceInfo.CreateReferenceInfo(ITaskItem referencePath)
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.ReferenceInfo.CreateReferenceInfos(IEnumerable`1 referencePaths)
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.TaskBase.Execute()
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
4>已完成生成项目“Microsoft.Extensions.DependencyInjection.Abstractions.csproj”的操作 - 失败。
4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\net7.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
========== 全部重新生成: 成功 3 个,失败 1 个,跳过 0 个 ==========

vs version 17.1.2

@ericstj what should I do

Activity

  1. ghost added
    untriaged
    on Mar 24, 2022
  2. Linlccc commented on Mar 24, 2022

    @Linlccc
    ContributorAuthor

    I clicked on the error message and jumped to C:\ProgramFiles\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets file, the following is the line information selected by the cursor

    <GenerateDepsFile ProjectPath="$(MSBuildProjectFullPath)"
                          AssetsFilePath="$(ProjectAssetsFile)"
                          DepsFilePath="$(ProjectDepsFilePath)"
                          TargetFramework="$(TargetFramework)"
                          AssemblyName="$(AssemblyName)"
                          AssemblyExtension="$(TargetExt)"
                          AssemblyVersion="$(Version)"
                          AssemblySatelliteAssemblies="@(IntermediateSatelliteAssembliesWithTargetPath)"
                          ReferencePaths="@(ReferencePath)"
                          ReferenceDependencyPaths="@(ReferenceDependencyPaths)"
                          ReferenceSatellitePaths="@(ReferenceSatellitePaths)"
                          ReferenceAssemblies="@(_ReferenceAssemblies)"
                          RuntimePackAssets="@(RuntimePackAsset)"
                          IncludeMainProject="$(IncludeMainProjectInDepsFile)"
                          RuntimeIdentifier="$(RuntimeIdentifier)"
                          PlatformLibraryName="$(MicrosoftNETPlatformLibrary)"
                          RuntimeFrameworks="@(RuntimeFramework)"
                          CompilerOptions="@(DependencyFileCompilerOptions)"
                          CompileReferences="@(ResolvedCompileFileDefinitions)"
                          ResolvedNuGetFiles="@(NativeCopyLocalItems);@(ResourceCopyLocalItems);@(RuntimeCopyLocalItems)"
                          UserRuntimeAssemblies="@(UserRuntimeAssembly)"
                          ResolvedRuntimeTargetsFiles="@(RuntimeTargetsCopyLocalItems)"
                          IsSelfContained="$(SelfContained)"
                          IncludeRuntimeFileVersions="$(IncludeFileVersionsInDependencyFile)"
                          RuntimeGraphPath="$(BundledRuntimeIdentifierGraphFile)"/>
    
  3. ericstj commented on Mar 24, 2022

    @ericstj
    Member

    This looks to me like the same issue as #40159. It shouldn't fail with a NullReference, that's tracked in dotnet/sdk#2716

    In those cases we were able to look at the ReferencePaths parameter (using https://msbuildlog.com) passed to GenerateDepsFile and found one reference missing version information from the FusionName metadata. In the cases we saw this happen it was sometimes caused by

    1. No up front build of the repo.
    2. Missing projects from the sln, where the project missing was the one identified in the log.
  4. Linlccc commented on Mar 26, 2022

    @Linlccc
    ContributorAuthor

    @ericstj I replied to you at dotnet/sdk#2716 (comment), I don't know if you see it, what should I do next

  5. ericstj commented on Mar 28, 2022

    @ericstj
    Member

    Your binlog is missing a lot of information. For example all the inputs to the failing task. For help on this issue please reply here, the SDK issue is tracking the bug in the task. Let's let this issue track getting you unblocked building the SLN (workaround that bug).

    Can you make sure to capture a full binlog? I believe this is a VS setting.

  6. Linlccc commented on Mar 29, 2022

    @Linlccc
    ContributorAuthor

    Thank you very much, my problem is solved now, but I don't know why, I can't build the project in VS, but I try to build in the command line and it is successful, I will upload the log file of this success, if you are interested It is helpful to use it, if not, please ignore it, thank you again here
    msbuild.zip

  7. ghost removed
    untriaged
    on Mar 29, 2022
  8. ericstj commented on Mar 29, 2022

    @ericstj
    Member

    It should build in VS. The fact that it doesn't is still a problem. I believe we can fix that problem with a change the SLN. If you get a chance to capture a full log in VS please capture and attach. If not someone on our side can try a repo and find out what's missing from the SLN.

    The SLN is not used for the command-line build.

  9. Linlccc commented on Mar 30, 2022

    @Linlccc
    ContributorAuthor

    After I successfully built the command line, I came back to VS and the build was successful. Now I can't reproduce that error here.
    But I found that this problem only occurs under the main branch of dotnet\runtime (I tried this on multiple computers),
    Because I tried to get other branches when I couldn't build before and restored it directly in VS and it was successful.

  10. ericstj commented on Apr 4, 2022

    @ericstj
    Member

    I couldn't reproduce your exact error, but I was able to reproduce something similar with some changes to the project. I added a project reference, built the reference, but not the src project, then tried to build the library (without adding the project to the SLN). This caused the error.

    Can you let me know what steps you were following before first opening the project in Visual Studio? Did you first do a build libs from the commandline or not? cc @ViktorHofer

  11. 12 remaining items

  12. ghost added
    in-pr
    on Apr 29, 2022
  13. ViktorHofer commented on Apr 29, 2022

    @ViktorHofer
    Member

    @Linlccc thanks again for sharing your feedback and the steps that you followed. #68668 should fix the underlying issue. Could you please checkout my branch and test the changes on your machine? I would expect that after an initial build of libs, the solution file should now work as expected.

    cd runtime
    git remote add ViktorHofer https://github.com/ViktorHofer/runtime
    git fetch ViktorHofer
    git checkout UpdateSlnsWithClosure
    git clean -xdf
    .\build.cmd clr+libs -rc Release
    .\build.cmd -vs Microsoft.Extensions.DependencyInjection.Abstractions
    

    That should allow you to both build and test inside Visual Studio successfully. Thanks

  14. Linlccc commented on Apr 30, 2022

    @Linlccc
    ContributorAuthor

    @ViktorHofer When I build directly in Visual Studio, there are still failures other than the "GenerateDepsFile" task
    Then I tried to build with msbuild in the command line with no problems again
    After building from the command line, back in Visual Studio and building again, there is no problem, the result is the same as before

    This gives me no clue, I don't know why I have no problems building from the command line, or building from the command line and then building with visual studio (without making any changes to the source code files), just Building directly in visual studio will have problems

  15. Linlccc commented on Apr 30, 2022

    @Linlccc
    ContributorAuthor

    @ViktorHofer I have a question, is there any difference between building with msbuild from the command line and building in visual studio
    I feel like they should all use msbuild's build, but there is an error that I can't understand, and there is no other place

  16. ViktorHofer commented on Apr 30, 2022

    @ViktorHofer
    Member

    Yes, Visual Studio uses the netframework flavour of msbuild, vs the CLI which uses the netcoreapp version.

    Can you please post the failures that you are still seeing when building inside VS?

  17. Linlccc commented on Apr 30, 2022

    @Linlccc
    ContributorAuthor
  18. ViktorHofer commented on May 1, 2022

    @ViktorHofer
    Member

    I meant either the error window or the output window log. The actual errors that you see inside VS.

  19. Linlccc commented on May 1, 2022

    @Linlccc
    ContributorAuthor
    4>------ 已启动全部重新生成: 项目: Microsoft.Extensions.DependencyInjection.Abstractions (src\Microsoft.Extensions.DependencyInjection.Abstractions), 配置: Debug Any CPU ------
    4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\net6.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
    4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\netstandard2.1\Microsoft.Extensions.DependencyInjection.Abstractions.dll
    4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018: “GenerateDepsFile”任务意外失败。
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018: System.NullReferenceException: 未将对象引用设置到对象的实例。
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.ReferenceInfo.GetVersion(ITaskItem referencePath)
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.ReferenceInfo.CreateReferenceInfo(ITaskItem referencePath)
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.ReferenceInfo.CreateReferenceInfos(IEnumerable`1 referencePaths)
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.TaskBase.Execute()
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    4>C:\Program Files\dotnet\sdk\6.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(172,5): error MSB4018:    在 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
    4>已完成生成项目“Microsoft.Extensions.DependencyInjection.Abstractions.csproj”的操作 - 失败。
    4>Microsoft.Extensions.DependencyInjection.Abstractions -> D:\Git\Github\runtime\artifacts\bin\Microsoft.Extensions.DependencyInjection.Abstractions\Debug\net7.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
    ========== 全部重新生成: 成功 3 个,失败 1 个,跳过 0 个 ==========
    

    vs version 17.1.2

    @ericstj what should I do

    Same as this

  20. eerhardt commented on May 1, 2022

    @eerhardt
    Member

    Looks to be the same as dotnet/sdk#2716

  21. ViktorHofer commented on May 2, 2022

    @ViktorHofer
    Member

    Right, @ericstj already linked to that issue earlier: #67091 (comment).

    I was hoping that making sure that all dependencies are part of the solution file would solve this issue but apparently it doesn't. I couldn't yet repro that issue so I'm wondering in which way @Linlccc's environment is different than any others.

  22. ghost removed
    in-pr
    on May 2, 2022
  23. ghost locked as resolved and limited conversation to collaborators on Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions