Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get a error MSB4062 with Build Wpf Project #2415

Open
koangel opened this issue Dec 19, 2019 · 13 comments
Open

I get a error MSB4062 with Build Wpf Project #2415

koangel opened this issue Dec 19, 2019 · 13 comments

Comments

@koangel
Copy link

@koangel koangel commented Dec 19, 2019

Issue I get a error MSB4062 with Build Wpf Project

1>------ 已启动全部重新生成: 项目: WpfSimple, 配置: Debug Any CPU ------
1>C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MSB4062: 未能从程序集 C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll 加载任务“Microsoft.Build.Tasks.Windows.MarkupCompilePass1”。未能加载文件或程序集“file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll”或它的某一个依赖项。系统找不到指定的文件。 请确认 声明正确,该程序集及其所有依赖项都可用,并且该任务包含实现 Microsoft.Build.Framework.ITask 的公共类。
1>已完成生成项目“WpfSimple.csproj”的操作 - 失败。
========== 全部重新生成: 成功 0 个,失败 1 个,跳过 0 个 ==========

Use .Net Core 3.1.00
System: Windows 7 sp1
Visual Studio 2019 Version: 16.4.2

Demo Project File Content:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

How to fix It?But, I can build with .net core 3.0

Path File tree:

C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\
tools\net472>tree /f
卷 系统 的文件夹 PATH 列表
卷序列号为 0000-40A4
C:.
│  PresentationBuildTasks.dll
│  System.Collections.Immutable.dll
│  System.Memory.dll
│  System.Numerics.Vectors.dll
│  System.Reflection.Metadata.dll
│  System.Reflection.MetadataLoadContext.dll
│  System.Runtime.CompilerServices.Unsafe.dll
│
├─cs
│      PresentationBuildTasks.resources.dll
│
├─de
│      PresentationBuildTasks.resources.dll
│
├─es
│      PresentationBuildTasks.resources.dll
│
├─fr
│      PresentationBuildTasks.resources.dll
│
├─it
│      PresentationBuildTasks.resources.dll
│
├─ja
│      PresentationBuildTasks.resources.dll
│
├─ko
│      PresentationBuildTasks.resources.dll
│
├─pl
│      PresentationBuildTasks.resources.dll
│
├─pt-BR
│      PresentationBuildTasks.resources.dll
│
├─ru
│      PresentationBuildTasks.resources.dll
│
├─tr
│      PresentationBuildTasks.resources.dll
│
├─zh-Hans
│      PresentationBuildTasks.resources.dll
│
└─zh-Hant
        PresentationBuildTasks.resources.dll
@scalablecory

This comment has been minimized.

Copy link
Member

@scalablecory scalablecory commented Dec 19, 2019

@vatsan-madhavan

This comment has been minimized.

Copy link
Member

@vatsan-madhavan vatsan-madhavan commented Dec 20, 2019

@kienlt2306

This comment has been minimized.

Copy link

@kienlt2306 kienlt2306 commented Dec 21, 2019

I met the same problem. Hope this is just bug
https://pasteboard.co/IMic7VB.png

@alexvkru

This comment has been minimized.

Copy link

@alexvkru alexvkru commented Jan 10, 2020

Hello, All! Me too met the same trouble. I have Windows 10 1803, build 17134.1184, VS Community 2019 16.4.2 and .Net Core SDK 3.1.100 (both, for x86 and x64). When i create new project WPF (.Net Core) I have similar error MSB4062 about file “file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dl". But this file exists in file system. What can I do for fix it?

@vatsan-madhavan

This comment has been minimized.

Copy link
Member

@vatsan-madhavan vatsan-madhavan commented Jan 10, 2020

Can you please share MSBuild binary logs corresponding to your failure?

https://aka.ms/msbuild/Binary-Log

@alexvkru

This comment has been minimized.

Copy link

@alexvkru alexvkru commented Jan 10, 2020

Hello, Vatsan Madhavan. Yes, of course. I created new project "WPF App (.NET Core)", named this as "wd". In opened VS IDE I see the not working constructor window with XAML editor below. In next second i see error, described above.

I made the binary log, please find the attached files (the log-file and the picture with the output from msbuild with errors)

out.zip
msbuildOutput

Thank's you!

@vatsan-madhavan vatsan-madhavan transferred this issue from dotnet/core Jan 10, 2020
@vatsan-madhavan

This comment has been minimized.

Copy link
Member

@vatsan-madhavan vatsan-madhavan commented Jan 13, 2020

@alexvkru Thanks for the prompt response and the log - I appreciate it.

Is there a chance you could reproduce this problem on an English language system, or set your UI locale to English and reproduce the problem again so that the msbuild logs are generated in English? I tried looking through the logs but it's going to take me a very long time to translate the strings in the log ad-hoc from Russian to English and investigate the problem that way...

@alexvkru

This comment has been minimized.

Copy link

@alexvkru alexvkru commented Jan 16, 2020

@vatsan-madhavan Hello, Vatsan! I'm now out of my work computer. I'll return at Jan/19/2020 and will make new binary log in English UI. Thank's You!

@msftbot

This comment has been minimized.

Copy link

@msftbot msftbot bot commented Jan 20, 2020

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions!

@alexvkru

This comment has been minimized.

Copy link

@alexvkru alexvkru commented Jan 20, 2020

@vatsan-madhavan Hello, Vatsan! I'm come back and made new bin log with a English UI locale. Please, see text output, picture and attached archive with binlog from msbuild

Text output:


** Visual Studio 2019 Developer Command Prompt v16.4.2
** Copyright (c) 2019 Microsoft Corporation


C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>msbuild.exe C:\Users\Алексей\source\repos\wd2020\wd\wd.sln /bl:C:\Users\Алексей\source\repos\wd2020\wd\out.binlog
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe /bl:C:\Users\Алексей\source\repos\wd2020\wd\out.binlog C:\Users\Алексей\source\repos\wd2020\wd\wd.sln
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 1/20/2020 12:20:31 PM.
Project "C:\Users\Алексей\source\repos\wd2020\wd\wd.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "C:\Users\Алексей\source\repos\wd2020\wd\wd.sln" (1) is building "C:\Users\Алексей\source\repos\wd2020\wd\wd\wd.csproj" (2) on node 1 (default targets)
.
C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MSB4062: The "Microsoft.Build.Tas
ks.Windows.MarkupCompilePass1" task could not be loaded from the assembly C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\t
ools\net472\PresentationBuildTasks.dll. Could not load file or assembly 'file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDe
sktop\tools\net472\PresentationBuildTasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration
is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask
. [C:\Users\Алексей\source\repos\wd2020\wd\wd\wd.csproj]
Done Building Project "C:\Users\Алексей\source\repos\wd2020\wd\wd\wd.csproj" (default targets) -- FAILED.

Done Building Project "C:\Users\Алексей\source\repos\wd2020\wd\wd.sln" (default targets) -- FAILED.

Deferred Messages

Detailed Build Summary

============================== Build Hierarchy (IDs represent configurations) =====================================================
Id : Exclusive Time Total Time Path (Targets)

0 : 0.233s 1.137s C:\Users\Алексей\source\repos\wd2020\wd\wd.sln ()
. 1 : 0.903s 0.903s C:\Users\Алексей\source\repos\wd2020\wd\wd\wd.csproj ()

============================== Node Utilization (IDs represent configurations) ====================================================
Timestamp: 1 Duration Cumulative

637151088320521669: 0 0.226s 0.226s ....
637151088322780495: 1 0.903s 1.129s ..................
637151088331811764: 0 0.012s 1.141s

Utilization: 100.0 Average Utilization: 100.0

Build FAILED.

"C:\Users\Алексей\source\repos\wd2020\wd\wd.sln" (default target) (1) ->
"C:\Users\Алексей\source\repos\wd2020\wd\wd\wd.csproj" (default target) (2) ->
(MarkupCompilePass1 target) ->
C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets(225,9): error MSB4062: The "Microsoft.Build.T
asks.Windows.MarkupCompilePass1" task could not be loaded from the assembly C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop
\tools\net472\PresentationBuildTasks.dll. Could not load file or assembly 'file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Windows
Desktop\tools\net472\PresentationBuildTasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the declaratio
n is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITa
sk. [C:\Users\Алексей\source\repos\wd2020\wd\wd\wd.csproj]

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:01.63

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community>


msbuildOutput

out.zip

@alexvkru

This comment has been minimized.

Copy link

@alexvkru alexvkru commented Jan 20, 2020

I updated Visual Studio to version 16.4.3 but the problem still remains

@vatsan-madhavan

This comment has been minimized.

Copy link
Member

@vatsan-madhavan vatsan-madhavan commented Jan 21, 2020

Paging @nguerrera @dsplaisted, the problem could be related to the URI encoding of (x86) in file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll

Assembly::LoadFrom doesn't seem to like the URL encoded form either:

C:\
λ  [System.Reflection.Assembly]::LoadFrom('C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll')
>>

GAC    Version        Location
---    -------        --------
False  v4.0.30319     C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll


C:\
λ  [System.Reflection.Assembly]::LoadFrom('file:///C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll')
>>

GAC    Version        Location
---    -------        --------
False  v4.0.30319     C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll


C:\
λ  [System.Reflection.Assembly]::LoadFrom('file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll')
>>
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Program Files
%28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll' or one of its dependencies. The system cannot
find the file specified."
At line:1 char:1
+ [System.Reflection.Assembly]::LoadFrom('file:///C:\Program Files %28x ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

C:\
λ  [System.Reflection.Assembly]::LoadFrom('C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll')
>>
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Program Files
%28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll' or one of its dependencies. The system cannot
find the file specified."
At line:1 char:1
+ [System.Reflection.Assembly]::LoadFrom('C:\Program Files %28x86%29\do ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

Going through the logs, Pbt.props is setting $(_PresentationBuildTasksAssembly) to C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll. After that, very next (and only) refererence to PresentationBuildTasks.dll is when MarkupCompileTask1 is about to run, and the UsingTask element is executed to load the DLL.

At this point, somehow (for reasons I don't understand yet) msbuild seems to be encountering AsssemblyFile=file:///C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\net472\PresentationBuildTasks.dll in the following UsingTask declaration:

<UsingTask TaskName="Microsoft.Build.Tasks.Windows.MarkupCompilePass1" AssemblyFile="$(_PresentationBuildTasksAssembly)" />

@vatsan-madhavan

This comment has been minimized.

Copy link
Member

@vatsan-madhavan vatsan-madhavan commented Jan 21, 2020

/cc @rainersigwald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.