Microsoft.Build.CPPTasks.Common cannot find Microsoft.Build.Tasks.Core - msbuild

I just upgraded a project from Visual C++ 2012 to Visual C++ 2017 and I'm getting build failures from MSBuild:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Current.targets(64,5): error MSB4062: The "SetEnv" task could not be loaded from the assembly C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.Build.CppTasks.Common.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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:\src\my-project.vcxproj]
The Fusion log shows bad things:
*** Assembly Binder Log Entry (2/12/2018 # 1:44:29 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Build.Utilities.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = msbuild.exe
Calling assembly : Microsoft.Build.CPPTasks.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Build.Utilities.Core, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core.EXE.
LOG: Attempting download of new URL file:///C:/windows/Microsoft.NET/Framework/v4.0.30319/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/VC/VCTargets/Microsoft.Build.Utilities.Core/Microsoft.Build.Utilities.Core.EXE.
LOG: All probing URLs attempted and failed.
Just posted this at Visual Studio Community but in another almost identical bug report they closed it as "Not a Bug" for reasons I cannot comprehend. I'm hoping StackOverflow will be more helpful. :)

Microsoft.Build.CPPTasks.Common cannot find Microsoft.Build.Tasks.Core
It seems you are using the old MSBuild.exe from .NET framework. You should use the MSBuild.exe from following location after you upgraded your project from VS2012 to VS2017:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
That because MSBuild is now part of Visual Studio!:
Starting with Visual Studio 2013, the 2013 version of MSBuild will
ship as a part of Visual Studio instead of the .NET Framework. This
transition allows us to more rapidly evolve MSBuild.
Hope this helps.

You will have to edit the file in this directory:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets
Called:
Microsoft.Cpp.Clang.targets
Edit line 17 into:
<UsingTask TaskName="ClangCompile" AssemblyFile="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.Build.CppTasks.Common.dll"/>
Be warned if this does create additional problems you might need to install proper MSBuild.

Related

CA0053 unable to load rule assembly rules.dll VS 2017

How to resolve this error
CA0053 CA0053 : Unable to load rule assembly 'c:\program files (x86)\microsoft visual studio\2017\enterprise\team tools\static analysis tools\fxcop\rules\rules.dll':
Could not load file or assembly 'file:///c:\program files (x86)\microsoft visual studio\2017\enterprise\team tools\static analysis tools\fxcop\rules\rules.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Tried to remove these tags from the project file, these tags doesn't exist in project file.
<CodeAnalysisRuleDirectories>…</CodeAnalysisRuleDirectories>
<CodeAnalysisRuleSetDirectories>…</CodeAnalysisRuleSetDirectories>
any other way of fixing this issue

Visual Studio 2015 not able to locate custom report assembly

I am getting this error in Visual Studio 2015 report project. This project builds fine in VS2012. I suspect VS2015 is not able to locate a custom assembly at compile time. But I am not sure which all paths it is searching.
Error [rsErrorLoadingCodeModule] Error while loading code module:
‘xxxx.Reports.SDK, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null’. Details: Could not load file or assembly
'xxxx.Reports.SDK, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. The system cannot
find the file specified.
I have already deployed my custom assembly on these locations but it did not help.
- C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies
- C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies
- C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting
Services\ReportServer\bin
- C:\Program Files (x86)\MSBuild\14.0\Bin
- C:\Program Files (x86)\MSBuild\12.0\Bin
Please help me resolve this issue. Thanks.
You should deploy your custom assembly to the VS2015 Folder for private assemblies (in standard installations: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies"

Could not load file or assembly 'Mono.Posix'

I'm attempting to run an exe on RHEL 6 using Mono. I've compiled Mono 4.0.2.4 and when I try to run my exe it crashes.
My Command:
/opt/mono/bin/mono /opt/mono/lib/mono/4.5/mono-service.exe -l:plexos.lock ./DALicenseServer.exe
The Error.
Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies.
File name: 'Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies.
File name: 'Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756'
I think I have the Mono.Posix.dll file:
ls /opt/mono/lib/mono/4.0/Mono.Posix.dll
/opt/mono/lib/mono/4.0/Mono.Posix.dll
This is a bug (Bug 56787) currently tracked by the Xamarin team. You must download and paste the missing dll in your environment then restart visual studio.
for vs 2015 paste here the dll:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Xamarin\Xamarin\
for vs 2017 paste here the dll:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Xamarin.VisualStudio
check this link for step by step: https://releases.xamarin.com/common-issues-in-the-xamarin-15-2-2-release-being-tracked-by-the-xamarin-team/
1) Try running mono with trace mode to see if it really is Mono.Posix.dll or a native shared library (.so) that is not being found.
mono --trace /opt/mono/lib/mono/4.5/mono-service.exe -l:plexos.lock ./DALicenseServer.exe
2) Check to see if the assembly has been installed properly in the GAC:
gacutil -l Mono.Posix
The following assemblies are installed into the GAC:
Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
Number of items = 1
3) If the assembly is not found in the GAC, something went wrong during the install (make install) as this assembly is part of the framework install. You can manually assign the MONO_PATH to tell mono where it should find assemblies that are not in the current directory ($PWD) and/or not in the GAC:
export MONO_PATH=/path/to/assemblies:/another/path/to/assemblies:$PATH

MSBuild with BizTalk failing

I am trying to set up a build server for BizTalk 2010 projects. I have installed the "Project Build Component" portion of BTS 2010 Enterprise only. However, I am getting the following error when trying to compile the solution:
C:\Program Files (x86)\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets(115,9): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [C:\CCNetBuild\FlexTMS.TLAutoTender.BizTalk\Trunk\Echo.BAS.TLAutoTender.Internal.Maps\Echo.BAS.TLAutoTender.Internal.Maps.btproj]
C:\Program Files (x86)\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets(115,9): error MSB4018: File name: 'Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\CCNetBuild\FlexTMS.TLAutoTender.BizTalk\Trunk\Echo.BAS.TLAutoTender.Internal.Maps\Echo.BAS.TLAutoTender.Internal.Maps.btproj]
C:\Program Files (x86)\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets(115,9): error MSB4018: at Microsoft.VisualStudio.BizTalkProject.Compiler.MapCompiler.Compile(BizTalkBuildSnapshot buildSnapshot, IEnumerable1 mapFilesToCompile, IEnumerable1 schemaFiles, List1& generatedCodeFiles, List1& xsltFiles) [C:\CCNetBuild\FlexTMS.TLAutoTender.BizTalk\Trunk\Echo.BAS.TLAutoTender.Internal.Maps\Echo.BAS.TLAutoTender.Internal.Maps.btproj]
C:\Program Files (x86)\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets(115,9): error MSB4018: at Microsoft.VisualStudio.BizTalkProject.BuildTasks.MapperCompiler.Execute() [C:\CCNetBuild\FlexTMS.TLAutoTender.BizTalk\Trunk\Echo.BAS.TLAutoTender.Internal.Maps\Echo.BAS.TLAutoTender.Internal.Maps.btproj]
C:\Program Files (x86)\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets(115,9): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\CCNetBuild\FlexTMS.TLAutoTender.BizTalk\Trunk\Echo.BAS.TLAutoTender.Internal.Maps\Echo.BAS.TLAutoTender.Internal.Maps.btproj]
C:\Program Files (x86)\MSBuild\Microsoft\BizTalk\BizTalkCommon.targets(115,9): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) [C:\CCNetBuild\FlexTMS.TLAutoTender.BizTalk\Trunk\Echo.BAS.TLAutoTender.Internal.Maps\Echo.BAS.TLAutoTender.Internal.Maps.btproj]
This error makes no sense. My understanding is that Visual Studio is no longer needed with the build components.
I would look at repairing the installation. You only need the build components and the SDK. Look here.
I will add the following to the previous answer, as my reputation at this point is < 50 and unable to add comments:
Microsoft Windows SDK for Windows 7 and .NET Framework 4 can be downloaded from here
Also please make sure your build command or build server is referencing MSBuild-32 bit (C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe) instead of 64 (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe)

MsBuild does not look in the good directory for custom task's second-level dependencies

I wrote a MsBuild Task : MyTask. In my solution, I have the Task project and others projects. MyTask references a project (say ProjA) which references third assemblies, say (dep1 and dep2).
The projects all builds well and I have the outputs in one directory (Compil). In this directory i have all the dll's I want : MyTask.dll, ProjA.dll, dep1.dll, dep2.dll and others.
In my MsBuild file i include the custom task assembly with :
<UsingTask AssemblyFile="..\Compil\MyTask.dll" TaskName="CreateSitesCss" />
Then I call a task of the MyTask assembly. The call is well executed but MsBuild complains about not finding the dep1 and dep2 assemblies (although they are in the same directory) :
error : Could not load file or assembly 'dep1, Version=2.0.0.0, Culture=neutral,PublicKey Token=9109c11469ae1bc7' or one of its dependencies. The system cannot find the file specified.
I can solve this problem by copying dep1.dll and dep2.dll to c:\windows\microsoft .net\framework\v4.0\ but I don't want to do this because it triggers problems when building other projects (won't copy the dep1.dll and dep2.dll to the output directory...).
Has anybody the same problem, or better, a solution?
EDIT
Here is the output of Fusion Log Viewer
*** Assembly Binder Log Entry (19/10/2010 # 17:52:45) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = HEADOFFICE\bbaumann
LOG: DisplayName = ProjA
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: ProjA | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
WRN: Not probing location file:///d:/svn/twilight/_build/ProjA.DLL, because the location falls outside of the appbase.
WRN: Not probing location file:///d:/svn/twilight/_build/ProjA/ProjA.DLL, because the location falls outside of the appbase.
WRN: Not probing location file:///d:/svn/twilight/_build/ProjA.EXE, because the location falls outside of the appbase.
WRN: Not probing location file:///d:/svn/twilight/_build/ProjA/ProjA.EXE, because the location falls outside of the appbase.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/ProjA.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/ProjA/ProjA.DLL.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/ProjA.EXE.
LOG: Attempting download of new URL file:///c:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/ProjA/ProjA.EXE.
LOG: All probing URLs attempted and failed.
And If I copy MsBuild.exe in the directory where all my dll are, it works fine...
MsBuild does not seem to look for dep1.dll and dep2.dll in my Compil directory even if it finds ProjA.dll within...
EDIT
As to how my bindings are done :
MyTask references the ProjA Project by :
<ProjectReference Include="..\ProjA\ProjA.csproj">
<Project>{ED61DCC3-D759-4D44-B802-A6A46F328402}</Project>
<Name>ProjA</Name>
</ProjectReference>
ProjA references the two dependencies by
<Reference Include="dep1, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Dependencies\dep1\dep1.dll</HintPath>
</Reference>
<Reference Include="dep2, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Dependencies\dep2\dep2.dll</HintPath>
</Reference>
You might try the Fusion Log Viewer (fuslogvw.exe, installed with VisualStudio) to see which paths are being searched for the assemblies. You may find another folder that can be used instead.
If dep1 and dep2 are third-party assemblies or internal ones that won't change, you could always throw them in the GAC. This is something I generally avoid on a build server, but if you are only using them for build helpers and not production installs it shouldn't be an issue.
Edit: The partial bind might be the cause. Are you using Assembly.Load to use ProjA? From the logs you provided, it looks like it is failing to load ProjA - it is not getting far enough to even try loading dep1 or dep2.
There are a couple of work arounds that I could sugest.
ILMerge this will allow you merge several Assemblies together, into one assembly.
You can add the secondary refence to your solution even though you are not using it, this would copy it to your bin folder.
create another Target to run after the compile to copy the missing Assembly to the folder
Hope this helps.
Iain