MSbuild 15.0 not building Xamarin Android - xamarin

I'm trying to upgrade our build process to use MSBuild 15.0 that comes with VS2017. Up to now we've been using MSBuild 14.0.
When I use MSBuild 15, I get this error.
C:\Program Files (x86)\MSBuild\Xamarin\Xamarin.Android.Sdk.props(16,3): error MSB4184:
The expression "[System.IO.File]::ReadAllText(C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\devenv.isolation.ini)" cannot be evaluated.
Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\devenv.isolation.ini'
It looks like $(VsInstallRoot) which is used by the props file is pointing to the wrong location.
Does anyone have any ideas about what might be going on or how to resolve this problem?
Thanks.

Turned out to be loser error, for part of the problem anyway. I'd installed MSBuild standalone tools and was trying to use that hence the VsInstallRoot problem.

In my case helped to uninstall separate MSBuild installation. I use MSBuild only in Visual Studio and through gradle plugin.

Related

Visual studio cannot build projects error "The target "ResolveCodeAnalysisRuleSet" does not exist in the project."

I was messing around with style cop and scrapped the idea in my project. I deleted the references to style cop and ended up modifying a system file somewhere.
Every project fails to build with the following error:
The target "ResolveCodeAnalysisRuleSet" does not exist in the project. CDRCallMonitor C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\Microsoft.CSharp.Core.targets 39
I scrapped my CSharp.Core.targets file and replaced it with the MS one online
https://referencesource.microsoft.com/#MSBuildFiles/C/ProgramFiles(x86)/MSBuild/14.0/bin_/amd64/Microsoft.CSharp.Core.targets
and this doesn't work.
I tried reinstalling msbuild tools and that didn’t help either.
I can't build anything with with msbuild/Visual studio
dotnet build works fine.
If you launch the Visual Studio installer there should be an option to uninstall, modify, or repair.
Give that repair option a go.

The "GetReferenceNearestTargetFrameworkTask" task was not found

I have a problem with autocompletion in VS 2017 Community.
Previously I had VS 2017 Enterprise from school, but the key expired so I moved to Community.
Before, everything works great, but now it doesn't work at all.
I found a solution on Stack Overflow here but it doesn't work, so found another solution at GitHub here.
And I got this:
Build FAILED.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1601,5): error MSB4036:
The "GetReferenceNearestTargetFrameworkTask" 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 in the project file, or in the *.tasks files located in the
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin" directory.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.11
Do you know what to do next?
I had the same error message but for a different problem.
So, I'm using MSBuild to automate build/deploy process for Azure Functions. Everything was working fine until I updated both Visual Studio 2017 and Visual Studio Build Tools 2017 at which point I started getting this error. To be precise I got this error only when using MSBuild, building project manually from VS was working fine.
In my case I already had everything set as per #Programmer's answer.
But as I was using MSBuild it turned out that I also had to install NuGet targets and build tasks which are part of Visual Studio Build Tools.
Follow these to fix that error. This applies to VS 2017:
Fix 1:
1.Install Nuget PackageManager from here.
2.Restart Visual Studio.
If the problem is still there, continue below
Fix 2:
1.Download and start/run the Visual Studio Installer again.
2.While the Visual Studio Installer is still running, go to the "Individual Components" tab
3.Tick the "NuGet package manager" check-box that is under "Code tools" option.
4.Click Install to install it.
Screenshot of where this is located:
That should fix the error you see in this question. Restart Visual Studio and test the auto-completion function. If it's not working, see the answers from this question as that is a whole different issue.
I was seeing this issue with msbuild 15.6.82 on a build environment that does not have VisualStudio 2017, only VS Build Tools.
Here's a PowerShell script that resolves this issue, it pretty much does the equivalent of previous answers in the VS Installer, but silently and waiting for completion.
Start-Process "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installer.exe" -ArgumentList 'modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" --quiet --add Microsoft.VisualStudio.Component.NuGet.BuildTools --add Microsoft.Net.Component.4.5.TargetingPack --norestart --force' -Wait -PassThru
I'm working with a headless build server on server core, resolved by installing chocolatey package choco install visualstudio2017-workload-webbuildtools from here:
https://chocolatey.org/packages?q=msbuild
I'm reporting an answer from a Microsoft techician
This usually indicates one of two things:
A failed VS installation. If that's the case, I would recommend running a repair on your VS install.
You have msbuild assemblies in the GAC. If that's the case, please ungac them.
Livar Cunha [MSFT]
I got the same problem in Visual Studio 2019, I solved it by simply install unity package

No TypeScript compiler was found at C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe

I installed Visual Studio 2015 and TypeScript 1.8.6 for Visual Studio 2015. After creating a new TypeScript project and building, I get this build error:
No compiler was found at C:\Program Files (x86)\Microsoft
SDKs\TypeScript\1.8\tsc.exe
Indeed, tsc.exe is missing in the file system.
Things I've tried:
Uninstall and re-install TypeScript Tools for Visual Studio 2015 1.8.6.0
Uninstall and re-install TypeScript Tools for Visual Studio 2013 1.8.5.0
Repair TypeScript Tools for Visual Studio 2015 1.8.6.0
I HAVE tried turning it off and on again :-)
Any clue on how to solve this? Which component installs the TypeScript SDK?
MSBuild is looking in the wrong place for tsc.exe
It should be looking in 'C:\Program Files (x86)\Microsoft SDKs\TypeScript\ tsc version \tsc.exe'
e.g. C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe
The one thing the TypeScript SDK installer wont do, is upgrade your existing projects. So all that reinstalling wont change anything. However, if you want MSBuild to use the newer compiler, you can upgrade your project yourself.
I don't think there is any way to do this through the UI, but it's easy enough to edit the Project file.
It needs to contain this in the first PropertyGroup
<TypeScriptToolsVersion>1.7</TypeScriptToolsVersion>
If you want the build to use v1.8.6, you need to set
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
In your case, I'm betting it's not there at all. So you should just add it.
I'm not experienced with using the TypeScript tools for Microsoft.. what you could do is use Gulp or Grunt tasks to compile TypeScript, this will even allow you to compile the TypeScript files everytime your save your .ts files.
You will need NPM (Node Package Manager) to install Gulp or Grunt and then install the package for compiling TypeScript.
You can find some information about the Grunt TypeScript package here: https://www.npmjs.com/package/grunt-typescript
Or for information about the Gulp TypeScript package, check this: https://www.npmjs.com/package/gulp-typescript
I've read through the comments on this issue on the TypeScript Github repo. Although this is a different issue, I did find a clue: repairing Visual Studio 2015 (through the Control Panel) installed tsc.exe in the correct folder.

error MSB4019: Microsoft.WebApplication.targets" was not found

I created a project using Visual Studio 2010 and trying to create the build in TFS 2013. I am getting the following error. Target Framework is 4.0. Why my build server is looking for Visual Studio 12.0 folder? How to change this settings? I appreciate any suggestions.
error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" was not found
Copy the directory "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0" from development machine to the build machine.
http://howtoscript.blogspot.com.tr/2014/05/error-msb4019-imported-project-cprogram.html?view=magazine
You need to do one of the following:
Change the build configuration to use 2010
Install VS 2013 on the build server.
I would recommend upgrading your visual studio anyway as you are already 2 versions behind with CTP's already available for DEV14,..

VS 2013 and MSBuild

I've recently upgraded to Visual Studio 2013, which has caused back to back problems when building externally using MSBuild (API or Executable with command line args)
Issue #1
When building with MSBuild it doesn't generate Fake assemblies which are required for our Unit Tests, this leads to build failures. A simple build in visual studio fixes this temporarily, until a new fake assembly needs to be generated.
Issue #2
When running code analysis this complains with the following:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(284,5):
error MSB4127: The "CodeAnalysis" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\CodeAnalysis\.\FxCopTask.dll".
Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.CodeAnalysis' to type 'Microsoft.Build.Framework.ITask'.
I only have Visual Studio 2013 installed on my machine, apparently installing an older version could fix the issue, but it's not something which I can do. (VS 2013 Ships with its own MSBuild 12.0 which is located in a different directory to the previous MSBuild).
I'm unsure why Visual Studio is behaving any differently to MSBuild, i'm simply pointing to the solution file like so...
msbuild.exe "path\solution.sln" /property:Configuration=Debug
So, Visual Studio 2013 comes with a new version of MSBuild i.e. MSBuild 12.0. Once installed, it changes the path so that the new version is used by default.
Looks like your solution compiles with visual studio 2012, you can either specify the full path to msbuild.exe such as
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "path\solution.sln" /property:Configuration=Debug
or set the visual studio 2012 environment variables by running the following before executing msbuild
"%VS110COMNTOOLS%"\vsvars32.bat // VS2012 environment variables
EDIT: Using MSbuild 12.0 assemblies "C:\Program Files (x86)\MSBuild\12.0\Bin\" fixes the issue with the code Analysis bug.

Resources