none
VS2017 .net Core api error

    Question

  • hello

    when i want to build a new .net core api project in VS2017 i got this error

    Severity    Code    Description    Project    File    Line    Suppression State
    Error    MSB4018    The "ResolveAssemblyReference" task failed unexpectedly.
    Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Unexpected CopyLocal flag.
       at Microsoft.Build.Tasks.CopyLocalStateUtility.IsCopyLocal(CopyLocalState state)
       at Microsoft.Build.Tasks.ResolveAssemblyReference.LogResults(ReferenceTable dependencyTable, DependentAssembly[] idealAssemblyRemappings, AssemblyNameReference[] idealAssemblyRemappingsIdentities, ArrayList generalResolutionExceptions)
       at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, GetLastWriteTime getLastWriteTime, GetAssemblyRuntimeVersion getRuntimeVersion, OpenBaseKey openBaseKey, GetAssemblyPathInGac getAssemblyPathInGac, IsWinMDFile isWinMDFile, ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader)
       at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute()
       at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
       at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()    CoreNet    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets    2041    

    i reinstall all component and ...

    i test on vscode and got this error to

      Restore completed in 78/82 ms for g:\Pasmand.API\Pasmand.API.csproj.
      Restore completed in 994/07 ms for g:\Pasmand.API\Pasmand.API.csproj.
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018: The "ResolveAssemblyReference"
    task failed unexpectedly. [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018: Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Unexpected CopyLocal flag. [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.CopyLocalStateUtility.IsCopyLocal(CopyLocalState state) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\CopyLocalState.cs:line 109 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.ResolveAssemblyReference.LogResults(ReferenceTable dependencyTable, DependentAssembly[] idealAssemblyRemappings, AssemblyNameReference[] idealAssemblyRemappingsIdentities, ArrayList generalResolutionExceptions) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\ResolveAssemblyReference.cs:line 936 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetLastWriteTime getLastWriteTime, GetAssemblyRuntimeVersion getRuntimeVersion, GetAssemblyPathInGac getAssemblyPathInGac, IsWinMDFile isWinMDFile, ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\ResolveAssemblyReference.cs:line 2319 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute() in E:\A\_work\45\s\src\Tasks\AssemblyDependency\ResolveAssemblyReference.cs:line 2939 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in E:\A\_work\45\s\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 631 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() in E:\A\_work\45\s\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 787 [g:\Pasmand.API\Pasmand.API.csproj]

    Build FAILED.

    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018: The "ResolveAssemblyReference"
    task failed unexpectedly. [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018: Microsoft.Build.Shared.InternalErrorException: MSB0001: Internal MSBuild Error: Unexpected CopyLocal flag. [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.CopyLocalStateUtility.IsCopyLocal(CopyLocalState state) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\CopyLocalState.cs:line 109 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.ResolveAssemblyReference.LogResults(ReferenceTable dependencyTable, DependentAssembly[] idealAssemblyRemappings, AssemblyNameReference[] idealAssemblyRemappingsIdentities, ArrayList generalResolutionExceptions) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\ResolveAssemblyReference.cs:line 936 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetLastWriteTime getLastWriteTime, GetAssemblyRuntimeVersion getRuntimeVersion, GetAssemblyPathInGac getAssemblyPathInGac, IsWinMDFile isWinMDFile, ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\ResolveAssemblyReference.cs:line 2319 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute() in E:\A\_work\45\s\src\Tasks\AssemblyDependency\ResolveAssemblyReference.cs:line 2939 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in E:\A\_work\45\s\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 631 [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() in E:\A\_work\45\s\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 787 [g:\Pasmand.API\Pasmand.API.csproj]
        0 Warning(s)
        1 Error(s)

    thanks


    • Edited by SMH.Fakhri Thursday, December 28, 2017 11:12 AM
    Thursday, December 28, 2017 11:11 AM

All replies

  • Hi SMH.Fakhri,

    Have you use any third-party extension? For example, Paket. There is a known issue about Paket:https://github.com/fsprojects/Paket/issues/2341

    And the workaround is using older paket <5.0.0.

    If you are not use any other third-party extension, please check the CopyLocalState.cs:line 109 if exists a flag CopyLocal, bcause error log report there is a unexpected copylocal flag in that file.

    MSB0001: Internal MSBuild Error: Unexpected CopyLocal flag. [g:\Pasmand.API\Pasmand.API.csproj]
    C:\Program Files\dotnet\sdk\2.1.3\Microsoft.Common.CurrentVersion.targets(2041,5): error MSB4018:    at Microsoft.Build.Tasks.CopyLocalStateUtility.IsCopyLocal(CopyLocalState state) in E:\A\_work\45\s\src\Tasks\AssemblyDependency\CopyLocalState.cs:line 109 [g:\Pasmand.API\Pasmand.API.csproj]

    Besides, if above not help you, you could send me a test sample, I would like check it.


    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 29, 2017 5:35 AM
  • thanks for your time

    but i have not this path in my computer E:\A\_work\45\s\src\Tasks\AssemblyDependency\CopyLocalState.cs

    and not use any third-party in my project

    when i create web api core project and built it got error

    Friday, December 29, 2017 2:51 PM
  • @SMH.Fakhri, if you got this error when you create web api core project and built it, it seems your Visual Studio installation file is damaged. You can try to repair your Visual Studio by Visual Studio Installer or reinstall your dotnet SDK.

    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 1, 2018 6:26 AM