Visual Studio online build failing with 0 warnings and 0 errors - visual-studio

I am just setting up a basic build with a very bare bones WebApi App, and I am getting a failed build, but without any errors or warnings... how can i figure out what is going wrong?
Project "d:\a\1\s\My.Project.Api.sln" (1) is building "d:\a\1\s\My.Project.Api\My.Project.Api.csproj" (2) on node 1 (default targets).
_CleanRecordFileWrites:
Creating directory "obj\Release\".
Done Building Project "d:\a\1\s\My.Project.Api\My.Project.Api.csproj" (default targets) -- FAILED.
Done Building Project "d:\a\1\s\My.Project.Api.sln" (default targets) -- FAILED.
Build FAILED.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.15
##[error]Process 'msbuild.exe' exited with code '1'.
Even any way I can get a useful log or error message would be great!
Edit:
I added /v:diag for the build arguments for verbose logging, but it really isn't seeming to help.

Before Visual Studio build task, you should use nuget restore to download packages your project is referring.
So please add a Nuget task before Visual Studio build task. Detail setting for NuGet task as below:
Command: restore
Path to solution, packages.config, or project.json: **/*.sln or select relative path for My.Project.Api.sln
Feeds to use: Feeds in my NuGet.config

In your build definition, there is a variable called system.debug which is set to false. Change this to true at the template or at the time of triggering and you will get the debug lines written by the build tasks. Inspect the debug lines and you might find the issue.

Related

Visual Studio target Deploy does not exist

I'm getting this error when running a built project in Visual Studio 2017:
------ Deploy started: Project: myProj, Configuration: Debug Win32 ------
C:\...\myProj.vcxproj : error MSB4057: The target "Deploy" does not exist in the project.
Done building project "myProj.vcxproj" -- FAILED.
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
I found something online saying uncheck Deploy from Build, Configuration Manager... but it is already unchecked.
If I try to run it again, it will load and run. But I'd like to be able to release code that works the first time. What else might I try? TIA.
Odds are you have a post build event in your project. When you first build it the post build event fires and attempts the deploy. The second time you go to build the project is already 'up to date' so it is not built and the post build event does not fire.
You can view your post build events by right clicking your project and choosing properties, expanding build events and then expanding post build.
You can also check if anything is defined under custom build steps.
Solved the problem by opening the .sln file of the problematic solution with a text editor. I've found there the following lines for different configurations:
{GUID}.Release|x86.Deploy.0 = Release|Win32
After deleting all these lines for different configurations, I didn't get the error anymore.
This worked for me :
GOTO "Project Property Page"
click "Project Dependencies"
Select your main project in "Project:"
Add the dependency on the project that gives you the deploy error.
Save ALL
Recompile

Build fails in vs2015 with no errors

I have an ASP.NET core 1.0 project I created in Visual Studio 2015 (update 3). If I try to build the project within VS I get the following in my output window and there are no errors in the Error List:
1>------ Build started: Project: QuickStartIdentiyServer4, Configuration: Debug Any CPU ------
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
However, if I build the project using the dotnet CLI command (dotnet build) it builds and runs just fine.
UPDATE:
Apparently, .net core does not work properly when running Visual Studio as Admin. You would think everything should work as Admin, I guess not... go figure.
There are simply too many reasons why this type of thing might happen. The easiest way to diagnose the problem is to change the build output verbosity under options to verbose. This might help put you on the trail:
With regards to this type of thing happening with .Net Core and ASP Core. I have noticed that the project.json dependencies json fragment is a bit buggy especially if you start renaming projects and changing their file system location.
If you see in the diagnostic below you know there is some dangling reference issue:
Done building target "_GetDependencyFragmentFiles" in project "<<?YOUR_CORE_PROJECT?>>.xproj" -- FAILED
May be you are not seeing build errors. Go to Error List window and change 'Show Issues generated' box from 'Build + Intellisense' to 'Build Only' and try to build again.
See if this helps.

Why does my TeamCity build fail, eventhough MSBuild has no errors?

TeamCity is set up to build a Visual Studio solution, which can be build locally by a number of developers. However, when TeamCity runs the build, it will always fail the build, even though MSBuild outputs no errors:
[08:49:02][Step 1/1] Process exited with code 1
[08:49:02][Step 1/1] MSBuild output
[08:49:02][MSBuild output]
[08:49:02][MSBuild output] 183 Warning(s)
[08:49:02][MSBuild output] 0 Error(s)
[08:49:02][MSBuild output]
[08:49:02][MSBuild output] Time Elapsed 00:01:10.65
[08:49:03][Step 1/1] Step Build solution (Visual Studio (sln)) failed
For comparison, these are the last lines of build output in a local Visual Studio:
54>
54>Build succeeded.
54>
54>Time Elapsed 00:00:11.37
========== Rebuild All: 46 succeeded, 0 failed, 18 skipped ==========
The curious thing is, I cannot find a line which says "Process exited with code 1" locally. I have turned of all pre/post build events for each project. I've looked for possible culprits throughout the build log from TeamCity, but I cannot find any clue related to why it exits with code 1.
Interestingly, the build does produce the necessary artifacts, which are valid!
Why is my build exiting with code 1?
EDIT in response to comments:
Same version of msbuild
running msbuild on the server in command line, generate a build.log file with the same results "x warnings, 0 errors". echo %errorlevel% returns 0.
there is no settings to "Treat warnings as errors"
I'll try to post to complete output, but i need to anonymize it first.
I can think of 3 issues:
It looks like TeamCity fails the build step if warnings are encountered - can you check that is not the case?
As others have commented, please try to do an ms build from the command line. Have a look at the exact command line argumes Team city is invoking msbuild with.
There are settings in the projects themselves to "treat warning as errors" but then msbuild would obey those rules. Did you customize your build ? For more info see this.

Visual studio compile output format

When compiling a C++ application with VisualStudio I noticed that each output line has a number in front of it. What does the "\d>" stand for?
Example:
4>ContentTimecodeConverter.cpp
1>avus_mpeg_stream_out.obj : warning LNK4221: no public symbols found; archive member will be inaccessible
4>ContentTarget.cpp
4>ContentBrowserWidget.cpp
1>Build log was saved at "file://d:\compile\release\libabc\BuildLog.htm"
1>libabc - 0 error(s), 1 warning(s)
You have concurrent building enabled, an option that enables building multiple projects at the same time. Each build running on one of the cores you have. Which inevitably causes their output to get intermingled. The number helps you keep track of which project produced the message.
It is configured with Tools + Options, Projects and Solutions, Build and Run, "maximum number of parallel build projects" setting.
It is a source of build breaks if you don't set the project dependencies correctly.

How do I parse the output of msdeploy and fail a TeamCity build if there are errors?

I'm using msdeploy.exe run from TeamCity for deploying ASP.Net projects to staging servers but if suffers severely from always returning a 0 status on exit, even when it raises several errors. This means that a bad deploy does not fail and all looks OK.
So I need to parse the output and have that raise an error, is there an easy way to do this? Alternatively, is there a hard way to do this?
You can see from the TeamCity build log below what is going on (errors, but carries on due to 0 exit status).
[17:32:31]: Skip copying Global.asax to obj\Debug\Package\PackageTmp\Global.asax, File obj\Debug\Package\PackageTmp\Global.asax is up to date
[17:32:31]: C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1845,5): error : Copying file Web.Debug.config to obj\Debug\Package\PackageTmp\Web.Debug.config failed. Could not find file 'Web.Debug.config'. [C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj]
[17:32:31]: Done Building Project "C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj" (Package target(s)) -- FAILED.
[17:32:31]: Build FAILED.
[17:32:31]: "C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj" (Package target) (1) ->
[17:32:31]: (ValidateGlobalPackageSetting target) ->
[17:32:31]: C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(817,5): error : '..\Package\WebApp.zip' exists as a file. You can't package as an archive directory to be the same path as an existing file. Please delete the file before packaging. Alternative,you can call msbuild with /t:CleanWebsitesPackage target to remove it. [C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj]
[17:32:31]: "C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj" (Package target) (1) ->
[17:32:31]: (CopyAllFilesToSingleFolderForPackage target) ->
[17:32:31]: C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets(1845,5): error : Copying file Web.Debug.config to obj\Debug\Package\PackageTmp\Web.Debug.config failed. Could not find file 'Web.Debug.config'. [C:\BuildAgent\work\f3548ee02a6397b9\webapp\WebApp.csproj]
[17:32:31]: 0 Warning(s)
[17:32:31]: 2 Error(s)
[17:32:31]: Time Elapsed 00:00:00.87
[17:32:31]: C:\BuildAgent\work\f3548ee02a6397b9>"C:\Program Files\IIS\Microsoft Web Deploy"\msdeploy.exe -verb:sync -source:Package=Package\WebApp.zip -dest:auto -setParam:"IIS Web Application Name"=MyWebName
[17:32:32]: Info: Updating setAcl (MyWebName).
[17:32:32]: Info: Updating setAcl (MyWebName).
[17:32:32]: Info: Updating setAcl (MyWebName/App_Data).
[17:32:32]: Total changes: 3 (0 added, 0 deleted, 3 updated, 0 parameters changed, 0 bytes copied)
[17:32:32]: Process exited with code 0
[17:32:32]: Build finished
TeamCity 7 has a Build Failures feature:
Edit Settings on your build configuration
Go to the Build Failure Conditions tab (number 4)
Click 'Add build failure condition'
Select the 'Fail build on specific text in build log' type
I used the string "EXEC : error count:" to catch MSDeploy errors, it works well
The Test button opens a handy dialog where you can test your failure condition on a previous build log that you know should have failed
Save
In my configuration I'm invoking msdeploy.exe directly from MSBuild, I think that's why my error text is different to yours.
Pretty cool, loving JetBrains for this.
Here is an approach I used to catpure build failures from MSDeploy when I ran a Nant script for deployment remotely. It is not an identical scenerio but should give you a concept to go from. Basically you can run this from a shell you need a scripting language like powershell to capture the output and than post processes the plain text coming back from msdeploy. I rasied this issue with the MSDeploy team and let them know this was a pain to deal with.
http://www.lostechies.com/blogs/hex/archive/2009/12/29/update-on-using-msdeploy-for-remote-deployments.aspx
In TeamCity 9 go to the build configuration and click on the Failure Conditions. Check the checkbox "an error message is logged by build runner". This will fail your build if an error happens during deployment.

Resources