MIBPostProcessDependencyGraph post build task fails in msbuild - c#

I have a visual studio solution with about 8 projects. 6 csproj and 2 vsxproj.
I had to migrate the proj files from VS 2010 to VS2017. So i started using the latest msbuild version for vs2017.
Faced a new post build error after this, that first says,
Done executing task "CL".
Task "CL"
Read Tracking Logs:
T:\components\collectors\buildoutput\x64\Release\tmp\hp-scom-.10EE536C.tlog\CL.read.1.tlog
Outputs for C:\USERS\_SDSBUILD\APPDATA\LOCAL\TEMP\.NETFRAMEWORK,VERSION=V4.0.ASSEMBLYATTRIBUTES.CPP:
T:\COMPONENTS\COLLECTORS\BUILDOUTPUT\X64\RELEASE\TMP\.NETFRAMEWORK,VERSION=V4.0.ASSEMBLYATTRIBUTES.OBJ
C:\Users\_sdsbuild\AppData\Local\Temp\.NETFramework,Version=v4.0.AssemblyAttributes.cpp will be compiled because it was not found in the tracking log.
Outputs for C:\USERS\_SDSBUILD\APPDATA\LOCAL\TEMP\.NETFRAMEWORK,VERSION=V4.0.ASSEMBLYATTRIBUTES.CPP:
T:\COMPONENTS\COLLECTORS\BUILDOUTPUT\X64\RELEASE\TMP\.NETFRAMEWORK,VERSION=V4.0.ASSEMBLYATTRIBUTES.OBJ
Write Tracking Logs:
T:\components\collectors\buildoutput\x64\Release\tmp\hp-scom-.10EE536C.tlog\CL.write.1.tlog
After this, there is another error.
Using "MIBPostProcessDependencyGraph" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.Build.CppTasks.Common.dll".
Task "MIBPostProcessDependencyGraph"
To improve incremental build performance for managed components, please make sure that the 'VC++ Directories->Reference Directories' points to all the paths which contain the referenced managed assemblies.
Could not load file or assembly 'general.Interop, Version=1.30.21.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
To improve incremental build performance for managed components, please make sure that the 'VC++ Directories->Reference Directories' points to all the paths which contain the referenced managed assemblies.
Could not load file or assembly 'Google.ProtocolBuffersLite.Serialization, Version=2.4.1.521, Culture=neutral, PublicKeyToken=55f7125234beb589' or one of its dependencies. The system cannot find the file specified.
To improve incremental build performance for managed components, please make sure that the 'VC++ Directories->Reference Directories' points to all the paths which contain the referenced managed assemblies.
Could not load file or assembly 'Collector2007, Version=3.10.18.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Done executing task "MIBPostProcessDependencyGraph".
Done building target "ManagedIncrementalBuildPostProcessDependencyGraph" in project
Not much information in the internet for this post build task MIBPostProcessDependencyGraph.
Could anyone please shed some light on this task and try to make me understand what this error is all about ?
Note: the compilation is done and the libraries are generated but this post build task failure causes some errors. SO wanted to understand and solve this.
Is ManagedIncrementalBuildPostProcessDependencyGraph not able to get the referenced libs while the compilation and pre compilation tasks were able to get those ?
Thanks in advance.

MIBPostProcessDependencyGraph post build task fails in msbuild
When you open the file Microsoft.Metagen.targets under the folder C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140:
<Target Name="ManagedIncrementalBuildPostProcessDependencyGraph"
Condition="'#(ClCompile)' != '' and '$(EnableManagedIncrementalBuild)' == 'True'"
DependsOnTargets="GetReferenceAssemblyPaths"
AfterTargets="$(ManagedIncrementalBuildProcessDependencyGraphAfterTarget)"
>
<PropertyGroup>
<MIBProcessDependencyGraphExcludedFolders Condition="'$(MIBProcessDependencyGraphExcludedFolders)' == ''">$(ExcludePath);$(FrameworkDir);$(VSInstallDir);$(_FullFrameworkReferenceAssemblyPaths)</MIBProcessDependencyGraphExcludedFolders>
<MIBSearchPaths>$(ReferencePath);#(ClCompile->'%(AdditionalUsingDirectories)'->Distinct())</MIBSearchPaths>
</PropertyGroup>
<MIBPostProcessDependencyGraph
Sources ="#(ClCompile)"
SearchPath ="$(MIBSearchPaths)"
ExcludedInputPaths ="$(MIBProcessDependencyGraphExcludedFolders)"
IntDir ="$([System.IO.Path]::GetFullPath($(TLogLocation)))"
ContinueOnError ="true"
TLogReadFiles ="#(CLTLogReadFiles)"
TLogWriteFiles ="#(CLTLogWriteFiles)"
/>
</Target>
It used to add the manage dll path to the MIB searching path. To resolve this issue, you can try to do as the the error messages said:
To improve incremental build performance for managed components,
please make sure that the 'VC++ Directories->Reference Directories'
points to all the paths which contain the referenced managed
assemblies.
You can check this thread for some details.
Hope this helps.

Related

CS1705 error while adding a C++ project to solution

Hi and thanks in advance.
I'm using TFS build 2013 (team services, not on premise) to build my solution. After creating a new C++ project in the solution I'm unable to build successfully.
The error I'm getting on the build machine is:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets
(219): An error has occurred during compilation. error CS1705: Assembly 'Microsoft.Build.Utilities.Core,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'Microsoft.Build.Framework,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher
version than referenced assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets
(219): The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name
of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask
interface. 3.) The task is correctly declared with <UsingTask> in the project file, or
in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\14.0\bin\amd64" directory.
I've red about error CS1705 on the internet but I still don't understand why I get this error - the project is an empty project which has no references what so ever and no other project reference it either.
I'm targeting .NET framework 4.6.1 on all my C# projects and in my build definition I'm adding these msbuild arguments: /tv:14.0 /p:VisualStudioVersion=14.0 hence it uses the 2015's version of the c# compiler.
The target platform for this C++ project is VS 2015 (v140) as follows:
C++ project configuration
Needless to say that when I'm removing this project from the list of project to build (configuration manager) - the solution builds successfully.
Any help/clue would be greatly appreciated!
The problem was something other than what I thought it was. Seems it's got something to do with CodeAnalysis and some environment variable related to it.
In my build definition I'm disabling CodeAnalysis and even inside the C++ project properties It's explicitly disabled. After I commented out some attributes on the "SetCABuildNativeEnvironmentVariables" target inside this file on the build machine:
"C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets"
The problem disappered.
This is a nasty workaround however since I'm not fully aware of what's really happening.
Thanks a lot anyways!
Seems there are something still point to "Microsoft.Build.Framework, Version=12.0.0.0"
The /tv:14.0 command argument doesn't work as expected. See:
BuildActivity ignores ToolsVersion
As a workaround, you need to customize the build process template:
Open the template in Visual Studio and find the Run MSBuild for
Project MSBuild activity.
Set ToolVersion to "14.0".
Set ToolPath to target to MSBuild14 (by default: "C:\Program Files
(x86)\MSBuild\14.0\Bin").
Check in this build process template and re-queue the build.
You can also refer the answer from Marson in TFS 2013 building .NET 4.6 / C# 6.0

Can't get ILMerge to build single-file console application that works

I'm trying to create a single-file executable. The code is .Net-based and also relies on some additional libraries including SQLite.
When I compile the source code, all of the relevant files go into the Release directory, although the SQLite DLL (sqlite3.dll) goes into a sub-directory (x86). I think this happens because I'm using SQLite-raw and that "spits out" both x86 and x64 copies of the DLL.
My initial command line to try is:
ILMerge /out:GEDtoRH.all.exe GEDtoRH.exe *.dll /target:exe /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2" /wildcards /log
This produces the following output that worries me:
AssemblyResolver: Assembly 'System.Runtime.WindowsRuntime' is referencing assembly 'System.Runtime'.
...
AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'System.Runtime.WindowsRuntime' is referencing assembly 'System.Threading.Tasks'.
...
AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
AssemblyResolver: Assembly 'System.Runtime.WindowsRuntime' is referencing assembly 'System.IO'.
...
AssemblyResolver: Did not find assembly in framework directory.
AssemblyResolver: Unable to resolve reference. (It still might be found, e.g., in the GAC.)
Location for referenced module 'sqlite3' is ''
Should I be concerned about the unresolved references? The reason I ask is because the finished executable doesn't work. It breaks with a null reference exception (Object reference not set to an instance of an object) on this line:
file = await StorageFile.GetFileFromPathAsync(filename);
The un-merged version of the executable works fine :( It isn't "filename" that is broken as I've tried adding some extra tests and it is fine.
Try as I might to add the sqlite3.dll to the list of things to ingest, if I try, ILMerge just complains with a "Could not load assembly" error.
As SQLite is not a .NET library it doesn't contain any IL to be merged

ILMerge: How to merge Azure runtime library?

I'm trying to use ILMerge to create a single executable that uses Windows Azure SDK 2.0 including the Microsoft.WindowsAzure.ServiceRuntime.dll, which I added manually because I couldn't find any NuGET package that contains it.
I'm using the following command line on a VS2012 post-build event:
/wildcards /targetplatform:"v4,C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" /log:ILMerge.log /closed Output.exe *.dll /out:Executable.exe
However, I'm getting the following error in ILMerge.log, even though the output window reports no issues at all after building:
The assembly 'Microsoft.WindowsAzure.ServiceRuntime' was not merged in correctly. It is still listed as an external reference in the target assembly.
An exception occurred during merging:
ILMerge.Merge: The assembly 'Microsoft.WindowsAzure.ServiceRuntime' was not merged in correctly. It is still listed as an external reference in the target assembly.
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
And then the executable throws the following exception when opened:
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.IO.FileNotFoundException: Could not load file
or assembly 'msshrtmi, Version=2.0.0.0, Culture=neutral, publicKeyToken=31bf3856ad364e35'
or one of its dependencies.
I have also tested the same output without merging and it works fine.
What am I missing here?
It would seem like this cannot be done, or at least not how I want it done.
Microsoft.WindowsAzure.ServiceRuntime.dll seems to have a dependency on the native library msshrtmi.dll. This means that ILMerge cannot handle it, since unmanaged code cannot be merged with managed code.
According to these two questions there is a way to work around this problem, but it involves packaging the msshrtmi.dllas a resource and unpacking it when it's needed. I feel it's kinda hacky.
So I guess I'll just have to do what I should have done before: remove all references to Microsoft.WindowsAzure.ServiceRuntime.dll from the project that builds the merged, non-Azure version of my WCF service. This might involve using some IoC container and doing some heavy refactoring, which is why I was trying to avoid it at this stage.

Migrator.NET MSBuild - Could not load file or assembly 'Migrator.Framework'

I've installed Migrator.NET using NuGet but when I attempt to run a migration using MSBuild I get the following error. I see that its having trouble accessing the Migrator.Framework assembly but I am unsure as to why or where specifically I need to put the DLL in order to get it to run.
C:\Users\Cody\src\App\App.Migrations\App.Migrations.csproj(64,5): error MSB4062: The "Migrator.MSBuild.Migrate" task could not be loaded from the assembly C:\Users\Cody\src\App\App.Migrations..\packages\MigratorDotNet.0.9.0.33276\tools\Migrator.MSBuild.dll.
Could not load file or assembly 'Migrator.Framework, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3b3586e9632ecfce' 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.
Does anyone have any insight? I've spent far too long fiddling with this.
It turns out the issue was in fact that it was looking for version 0.0.0.0. I downloaded the project and recompiled the Migrator.Framework binary as version 0.0.0.0 as a quick fix. The real solution is recompiling Migrator.MSBuild.dll to look for the proper version of Migrator.Framework.
I'll see if this was a one-off error or if I can reproduce it, and submit it as a bug to the Migrator.NET team if it is in fact a bug with the NuGet package.

Problem with error messages in solution

I have a solution with around 10 projects, I have not written any of this myself, but I'm going to take over a project here. The project that is the main project is based on WPF. When I try to run this project, I get the following compiler error:
The tag 'RoutingManagerView' does not exist in XML namespace 'clr-namespace:RoutingManager.Views;assembly=RoutingManager'. Line 29 Position 14. C:\Source\WSA\WsaClient\Views\MainView.xaml 29 14 WsaClient
Then, if I double click this error message, so that the xaml is opened, and the designer is loaded, the designer does not load, and I get 3 more error messages:
Unable to load the metadata for assembly 'WsaClient'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'WsaClient' or one of its dependencies. The system cannot find the file specified. C:\Source\WSA\WsaClient\Views\MainView.xaml 1 1 WsaClient
Unable to load the metadata for assembly 'RoutingManager'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'RoutingManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. C:\Steria\Forsvaret\P6088\Source\WSA\WsaClient\Views\MainView.xaml 1 1 WsaClient
The type 'Views:RoutingManagerView' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. C:\Source\WSA\WsaClient\Views\MainView.xaml 29 14 WsaClient
I googled it, and many have suggested that this is because a DLL is locked since it originates from the internet. However in my condition, I do not have a DLL. It's complaining on two projects that are a part of the solution, WsaManager and RoutingManager. I got all the source code on a zip file on an usb pen, and I have extracted it to somewhere on my c drive, so there is no remote access of the code.
If anyone have had the same or similar problem earlier, I would highly appreciate any pointers here on how to resolve this.
EDIT
The last error message is given on this line in the XAML file:
<Views:RoutingManagerView DataContext="{Binding Dependency}"/>
And on the top of the XAML file, this is the import for the assembly:
xmlns:Views="clr-namespace:RoutingManager.Views;assembly=RoutingManager"
Resolve this by right clicking on the solution and choosing 'Rebuild Solution'
An additional point for other readers: if your projects builds successfully, but you get this error message while trying to load your view in the designer, make sure your assembly is x86 or Any CPU, because Visual Studio 2010 is a 32bit process and cannot load x64 assemblies in the designer.
To resolve this problem, I had to compile the projects one by one, starting from the project with no dependencies on other projects, and then working my way "up".
It seems that the Build all did not manage to do this properly automatically.
Try this, this was the only advice that worked for me:
Unable to load the metadata for assembly ''. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545.  The following error was encountered during load: Could not load file or assembly '' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
In WPF project to allow the project to load from remote source we have to enable it in the configuration file devenv.exe.config.
Step 1: Search the configuration file devenv.exe.config in your system. Usually it is located at
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config
Step 2: Edit the configuration file. Add following line in the tag
<loadFromRemoteSources enabled="true" />
Step3: Restart your visual studio.
http://exacthelp.blogspot.cz/2012/02/unable-to-load-metadata-for-assembly.html
Unable to load the metadata for assembly 'WsaClient'. This assembly
may have been downloaded from the web. See
http://go.microsoft.com/fwlink/?LinkId=179545. The following error was
encountered during load: Could not load file or assembly 'WsaClient'
or one of its dependencies. The system cannot find the file specified.
C:\Source\WSA\WsaClient\Views\MainView.xaml 1 1 WsaClient
I run into same error: I can build and run my project, but I can not design XAML. I realized that it was local configuration issue because it's not replicable on my other machine (using same repository revision).
I started digging more and figured out that VS 2010 does not like # symbol in path. So error shows up when I have my sources in
C:\#projects\<my project>
After I moved them to
C:\projects\<my project>
Problem is gone.
I hope this will help to someone else.
I suspect the ..
The tag 'RoutingManagerView' does not exist in XML namespace 'clr-namespace:RoutingManager.Views;assembly=RoutingManager'. Line 29 Position 14. C:\Source\WSA\WsaClient\Views\MainView.xaml 29 14 WsaClient
.. error is causing a cascade of other errors. It looks like you're trying to create a RoutingManagerView from the namespace RoutingManager.Views in the assembly RoutingManager. However, it is not there. Make sure the class is visible to the outside world. Or try to clean and rebuild the solution and see on which project the first error occurs. Because if the projects are interdependent, an error in one project might cause reference errors in others.

Categories