Error MSB4184: The expression """.sourcesDirectory" cannot be evaluated. Method 'System.String.sourcesDirectory' not found - msbuild

I am trying to build a VS2019 ASP .NET Web application project in Azure DevOps, I am getting the error mentioned as below.
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2293,9): Error MSB4184: The expression """.sourcesDirectory" cannot be evaluated. Method 'System.String.sourcesDirectory' not found.
Error
Same if build VS2015 project in Azure DevOps it's working fine. Is there any issue with the VS2019 MS Build tool?
My pipeline setup
I have tried all the possible solutions, is I am missing any step or parameter for the sourcedirectory?

Related

Unable to Detect Error through Build Definition

I Have created a build definition for ASP.net core 2.2 application on .sln file,
i intensionally commited wrong code which i will get build error in visual studio 2017, but when build definition is run build task it is not showing any error and build is also passing ....please help me
following picture are my build definition

Appveyor CI fails to build a .net core 2.1 solution with a database project

Our .net core 2.1 solution compiles fine on our local development machines with .net core sdk 2.1.301. Appveyor used to compile the solution in its CI pipeline when there was no database projects defined. Once such a project added, Appveyor started failing in building the solution with the error message below. Any clues how to address this issue?
C:\projects\comingsoon\ComsingSoonDatabase\ComsingSoonDatabase.sqlproj(57,3):
error MSB4019: The imported project "C:\Program
Files\dotnet\sdk\2.1.300\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets"
was not found. Confirm that the path in the declaration is
correct, and that the file exists on disk.
The database project can only be built using the full framework MSBuild tools included in visual studio.
Depending on how you set up appveyor, you need to change your definition to use msbuild.exe instead of dotnet commands.

NuGet restore works, but compile fails on build server

I am trying to build a .NET 4.6 project using MSBuild 15 on our build server (using CruiseControl).
The project has a NuGet package reference (to Oracle.ManagedDataAccess) and it gets restored correctly.
However, the build task fails with the error "The type or namespace name 'Oracle' could not be found".
I have tried building the project in VS 2017 on the build server using the same account, and it works.
I expected MSBuild to retrieve the package contents from the same location, but apparently it can't. What could be the reason?
The error seems to have been caused because MSBuild 14 was used in the build task instead of MSBuild 15. Not sure exactly why that made it fail, but it works now.

.NET Standard and TFS 2015 -> Build failures

My infrastructure now has TFS 2015, but we started a new project in .NET Standard. Our build server now has VS2017, and the project builds when loaded within VS2017 in that server.
When we set a new build definition to run the build through the build agent, then it fails. Seems even that System is not found:
Error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
Is there any simple thing to do to make it work, ir we will have to migrate to the new build steps to make it work? Some workaround?
I find a workaround for that. Simply I gave up of using the TFS 2015 build steps MSBUILD and Visual Studio Build, and now I am using the Command Line step. Calling the commands from there:
dotnet restore
dotnet build
That does the trick.
This is because we need to do our restore a different way using the .net core restore. You could fix this by adding the .NET Core (PREVIEW) task to the build definition or just use command line task. With command line task could running dotnet restore, dotnet build, dotnet publish, and dotnet test.
More details please take a look at this blog: Setting up .net core continuous integration build with VSTS/TFS
For command line solution please refer vsts-agent Build Definition for .NET Core (with Test Results) Also take a look at this similar question: Visual studio team services build .net core 1.1

.NET 4.5.1 broke MSBUILD

We've been using TeamCity for some time without issues. We went a few weeks without doing builds and our server team installed .NET 4.5.1 on the server. Now all of our builds are breaking.
Here is the command line being ran (edited for privacy):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>msbuild "C:\programs\TeamCity\bu
ildAgent\work\<path to proj file>.csproj" /t:Package /P:Configuration=Test
Which results in this error:
The target "Package" does not exist in the project.
Lots of results talk about this being a missing visual studio folder named "web" or not having web deploy installed. That is not the case here. Those solutions are not working.