Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio MSBuild errors

I installed Visual Studio 2013. Previously my project was built in VS 2010.

I opened my project in VS 2013 and the project was automatically updated. I've also updated the project build options to use .Net 4.5.3 instead of 4.0.

The project builds and runs with no errors. But I see more than 100 warnings that I haven't seen before -- all related to the file Microsoft.Common.CurrentVersion.target.

The first warning, for example is:

The 'TreatAsLocalProperty' attribute is not declared.

I'm not familiar with the Microsoft.Common.CurrentVersion.target file. When I examine the warnings, I see that this file is coming from msbuild\12.0\bin directory.

I see that I also have an msbuild\14.0\bin directory, although the file there looks very similar. I think maybe this was installed as part of the VS 2013 install -- maybe I should be using that version of msbuild(?) -- but I am not sure where to change that and also not sure that would fix the problem. I changed my .csproj file to reference version 14:

<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

But that had no effect.

Maybe there is something else that needs to be included in the project?

like image 934
George Hernando Avatar asked Dec 19 '14 20:12

George Hernando


People also ask

How do I fix Visual Studio build errors?

To get help on a particular diagnostic message in Visual Studio, select it in the Output window and press the F1 key. Visual Studio opens the documentation page for that error, if one exists. You can also use the search tool at the top of the page to find articles about specific errors or warnings.

How do I run MSBuild in Visual Studio?

With Visual Studio 2019 and later, it's installed under the Visual Studio installation folder. For a typical default installation on Windows 10, MSBuild.exe is under the installation folder in MSBuild\Current\Bin. In the installer, make sure MSBuild tools for the workloads you use are selected, and choose Install.

How do I show build errors in Visual Studio?

To display the Error List, choose View > Error List, or press Ctrl+\+E.

Does Visual Studio call MSBuild?

Visual Studio uses MSBuild, but MSBuild doesn't depend on Visual Studio. By invoking msbuild.exe or dotnet build on your project or solution file, you can orchestrate and build products in environments where Visual Studio isn't installed. Visual Studio uses MSBuild to load and build managed projects.


1 Answers

This link helped me microsoftcommontargets errors and over a hundred warnings. The answer by Cool Coyote did the trick:

I had this error appear 1 day after rearranging a large project. I finally solved the problem by closing down every source window. I had been veiwing references in my project and had a fair few windows open. When everything was closed I tried a run , which built and run ok to my surpise with absolutely no warnings. I find the environment does get corrupt now and then, usually a restart does the trick but in this case thr problem just repeated. Cleaning the ide by closing the window takes the memeory load of the ide, Im suspicious of internal corruptions when this sort of thing happens.

So I closed all the source windows, did a Solution > Clean, and a Solution > Rebuild...and no more of those warnings!

like image 112
Opus4210 Avatar answered Oct 22 '22 12:10

Opus4210