AutoUnify stopping rollback from Azure 2.5 to Azure 2.3 - visual-studio

My team recently tried to upgrade our WorkerRoles project to use Azure 2.5. But I've spent days on it and have had no joy resolving some weird worker role recycling issues and due to time pressure we're rolling back to Azure 2.3.
However, after changing all the references and the app.config file, when I try to run I get the following exception:
System.IO.FileLoadException was unhandled
Message: An unhandled exception of type 'System.IO.FileLoadException' occurred in WaWorkerHost.exe
Additional information: Could not load file or assembly 'Microsoft.WindowsAzure.Diagnostics, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I tried changing my app.config bindings, etc. And it seems fine to me. Then I noticed a warning in the error console:
Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
So I ran my build again with the "give me lots of info" setting and I think I've found the issue:
2> Unified Dependency "Microsoft.WindowsAzure.ServiceRuntime, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
2> Using this version instead of original version "2.3.0.0" in "C:\Users\craig.brett\repos\Admin\WorkersPlus\bin\Craig\WorkersPlus.dll" because AutoUnify is 'true'.
2> Resolved file path is "C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\ref\Microsoft.WindowsAzure.ServiceRuntime.dll".
...
2> Unified Dependency "Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
2> Using this version instead of original version "2.3.0.0" in "C:\Users\craig.brett\repos\Admin\WorkersPlus\bin\Craig\WorkersPlus.dll" because AutoUnify is 'true'.
2> Resolved file path is "C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.5\bin\plugins\Diagnostics\Microsoft.WindowsAzure.Diagnostics.dll".
This all looks very suspect to me, when I'm trying to get it to use 2.3. Is there something I need to do to roll back to 2.3? Do I have to uninstall (or attempt to) the Azure 2.5 SDK entirely?

Thanks to Simon Opelt's comment, I went back and did a git diff against the version prior to the update focused on the effected projects.
They revealed that the Azure Caching NuGet package was still at version 2.5, as well as the several sub-libraries of it. There were also a few other Microsoft.* packages that had gone up a few versions. So I used code similar to the following to selectively go through and revert the changes:
git checkout -p <hash of commit prior to Azure upgrade> -- ProjectWorker\ProjectWorker.csproj
git checkout -p <hash of commit prior to Azure upgrade> -- ProjectWorker\packages.config
I took no chances and also rolled back the Azure ServiceBus package.
After this process, things ran fine again! Not quite as easy as it should have been, but at least we're working again and can upgrade at a later date.

Related

UWP and Xamarin Builds Failing with no output

I have tried creating Android projects and cross platform projects that utilize Xamarin in Visual studio. When I build, even an empty project, it fails instantly without seeming to perform any work.
There are no errors or warnings listed.
The output window has the project name and:
Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped
When I start the project I get message boxes warning me about unexpected logger failures and sometimes the dialogs reference the MuxLogger. This is inconsistent, the messages vary slightly and sometimes don't appear at all. Here is an example:
Incidentally I tried manually building to get more output and I get this:
Unhandled Exception: System.TypeLoadException: Could not load type 'Microsoft.Build.Logging.ProfilerLogger' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Exception.GetStackTrace(Boolean needFileInfo)
at System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
at System.Exception.ToString()
at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)
at Microsoft.Build.CommandLine.MSBuildApp.Main()
Note that I can build many other project types such as web projects and MonoGame projects just fine.
Ultimately this turned out to be a problem with an old version of MSBuild installed in the Global Assembly Cache (GAC). To check for this, first open an instance of Developer Command Prompt for VS2017. Then output the assemblies in your GAC to a file for easy review:
gacutil -l >> someFile.txt
Look for anything that starts with Microsoft.Build, specifically lines that include Version=15.X (hint, these don't output in order so sort the lines alphabetically).
Uninstall all things that start with Microsoft.Build which may include Microsoft.Build.Framework, Microsoft.Build and more. This should not install versions of Microsoft.Build with a version < 15. Command:
gacutil -u Microsoft.Build
and
gacutil -u Microsoft.Build.Framework
This should allow your project to utilize the correct version of MSBuild and compile successfully.

Failed to resolve assembly : 'Java.Interop'

When I try to build the application I get an exception the following exception :
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
I tried cleaning the project and building it again, also updated the Xamarin.Forms packages but still with no luck.
A little overview on the stack trace :
2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
2> Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch execution finished. (TaskId:153)
2> MTouch: 2016-07-05T14:27:15.8191415+05:30 - Finished (TaskId:153)
2> Output Item(s): _NativeLibrary= (TaskId:153)
2>Done executing task "MTouch" -- FAILED. (TaskId:153)
Has anyone received this error? I am running the latest Xamarin for Visual Studio.
As mentioned in the comments above by #SushiHangover Java.Interop.dll is from Xamarin.Android and I was getting an error in Xamarin.IOS.
I had a reference of Mono.Android in PCL which is always referenced in Xamarin.IOS so indirectly I was referencing dll of Xamarin.Android to Xamarin.IOS. Removing the reference from PCL solved my problem.
Step-by-step instructions on how to fish this one out, as it took me some time to find where the 'Android polluted' peace of code was.
Unload your Common code project
Open .csproj look for something like this
<ItemGroup>
<Reference Include="Mono.Android">
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\Mono.Android.dll</HintPath>
</Reference>
Delete this segment from csproj.
Load the project
Clean and rebuild the solution having iOS as startup Project, at this point, you will get a build error that will show which .cs file fails to build due to missing reference.
Go there and move the mechanism to an Android specific project.
As mentioned by #AkashAmin 'Mono.Android' referenced should not be there in PCL project.
But with this, also make sure that you have not added any 'Android' specific code in PCL project by adding 'using Android', if this was done then you need to remove this code by using 'Dependency Services', Click here
I had the same problem and when I removed the android.mono reference from pcl project it worked fine.
I think it happens because we are building project in ios and it doesn't have any android libraries
Platform specific code within the Shared Project will cause iOS compiler to attempt to use the platform specific assemblies when compiling.
In my case, I had a reference within my Shared Project's code, within the "using" statements, which was causing iOS to attempt to link to Android specific assemblies.
Removing the code from the Shared Project allowed for successful compiling of the project.
Just in case, I got this error from working with ReSharper on VS2013 (https://bugzilla.xamarin.com/show_bug.cgi?id=41627).
What I did was use the Workaround to explicitly add java.interop.dll assembly to my project. This problem doesn't affect Build so you can deploy first and VS will download java.interop to your app's obj\Debug\linksrc folder, which you can reference...
You need to check your PLC project on Android link. In PLC project ctrl+f and lets go find "Android" and delete it.

LinkAssemblies fails after upgrading to MVVMCross 4.0

I have just updated a large Xamarin project from MVVMCross version 3.5 to 4.0. I have fixed all namespace issues and bugs, but I am stuck with this bug:
The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item
'System.Boolean Android.OS.BaseBundle::GetBoolean(System.String,System.Boolean)'
(defined in 'MvvmCross.Droid.FullFragging, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=null') from 'MvvmCross.Droid.FullFragging, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=null' could not be resolved. --->
Mono.Cecil.ResolutionException:
Failed to resolve System.Boolean Android.OS.BaseBundle::
GetBoolean(System.String,System.Boolean)
I have added MvvmCross.Droid.FullFragging.* to linkerConfig.xml, but to no avail.
I experienced the same issue. The MvvmCross dlls are build to version v6.0 for android. I noticed the following output tab (My logging is set to verbose).
warning XA0105: The $(TargetFrameworkVersion) for MvvmCross.Binding.Droid.dll (v6.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0).
When I changed the projects to Android 6.0 I still received the linker error. When I opened the project file in a text editor I noticed that was defined twice. Once in the global property group set to 6.0 and once in the Debug property group set to 5.0. I removed the following line from the Debug property group and the issue went away.
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
What you need to do is to switch on verbose logging in your build. For iOS specify verbose logging by adding:
-v -v -v -v
To the extra build parameters textbox. Then run the build again.
For Android you can do this in the Visual Studio Tools -> Settings -> Xamarin -> Android settings -> Xamarin Diagnostics.
You will probably identify that some packages are of different versions and will cause this linking issue.
You will find some clues to the issue using verbose logging. I have only mentioned the verbose logging for this platform as its the platform I have most experience with at the moment.
This is the best answer I can offer as this issue can be caused by a truly massive number of issues and will be individual to each solution.

MsBuild error MSB1025 - System.Threading.Tasks.Dataflow not found (following fake generation problems)

I have a problem with the standard MSBuild.exe used on our Team Build server, the standard version used is in
"C:\Windows\Microsoft.NET\Framework\v4.0.30319", version 4.0.30319.18408 or
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319" respectively (same version).
Using this version leads to Fake dlls not being generated in the same way as on our local development machines (i.e. some fake methods are missing on the server), resulting in broken builds (unit tests) on the TFS.
I updated the build definition template to use the MSBuild version located under "C:\Program Files (x86)\MSBuild\12.0\Bin" as it is more recent (version 12.0.30723.0), however, this results in an error MSB1025, System.Threading.Tasks.Dataflow, Version=4.5.9.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a not found.
Update
Further investigation - manually adding the System.Threading.Tasks.Dataflow.dll with the correct version number to the MSBuild directory results in a broken build with
Unsupported ToolsVersion 12.0
Manually setting the ToolVersion in the Microsoft.TeamFoundation.Build.Workflow.Acitvities.MSBuild element to "4.0" results in a broken build with
Cannot set unknown member "Microsoft.TeamFoundation.Build.Workflow.Activities.MSBuild.ToolVersion"
So... no real improvement.
Any ideas how to fix this?
Fakes is sensitive to the Visual Studio version. Try passing /p:VisualStudioVersion=12.0 to MSBuild arguments. Also avoid handling System.* assemblies manually.

Visual Studio Web Site ": Build (web): The file name already in the collection"

I'm working on a web site (not web application) project in Visual Studio 2013 and have intermittent build issues. The build output shows each directory building (e.g. "Building directory '/User/'."). However, more often than not, on different directories, during different build attempts, I receive the following error (note the filename changes):
The file name 'C:\Users\xxxx\AppData\Local\Temp\2\Temporary ASP.NET Files\root\25143ee9\2d39f4f7\yhzrc1w3.pdb' was already in the collection. Parameter name: fileName
And the following build output:
: Build (web): The file name 'C:\Users\xxxx\AppData\Local\Temp\2\Temporary ASP.NET Files\root\25143ee9\2d39f4f7\yhzrc1w3.pdb' was already in the collection.
I have tried deleting everything from the temp directories, restarting visual studio, bypassing Visual Studio (building with aspnet_compiler), and doing a rain dance. However, no matter what I try builds intermittently fail.
Is there any way to see more granular output from the build process in Visual Studio? I've already tried setting the build output to detailed ("Tools"-->"Projects and Solutions"-->"Build and Run"-->"MSBuild project build output verbosity:"). Any ideas would be greatly appreciated!
Thank you!
I ended up finding out what was causing the problem.
I had upgraded from ReportViewer 10 to ReportViewer 11 and the following line was added to the web.config:
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</buildProviders>
This was causing the intermittent build failures. I removed the buildProvider tag and it builds and deploys just fine.

Resources