Build using TeamCity: Failed to start MSBuild; please specify a nuspec or project file to use - msbuild

I'm trying to build a website in Teamcity, but the first build step "starting MSBuild" is failing.It seems that the command is trying to install nuget, but it is complaining that there is no nuspec or project file specified.
I have a "nuget.targets" file and the code compiles fine outside of teamcity , so I think it must be a setting I am missing, and not a file I actually need to add but maybe I do need to add a nuspec or project file? Assuming I do, how would I go about doing that?
[Exec] C:\TeamCity\buildAgent\work\61cf1fbc18b86c6f\.nuget\NuGet.targets
(109, 9): Please specify a nuspec or project file to use.
I am completely new to Teamcity (~3hrs); how do I resolve this problem?

If a build fails or behaves differntly in TeamCity than locally, then it is recommended to run the build in the working folder on agent machine under the same user that the agent is running. Find more details here.

Related

How to create Azure Cloud Service package from MsBuild in azure pipeline

I have some cloud service projects , which i am trying to get it into CI/CD. When i right click on the project from Visual Studio and click Package it does what i want. I can see the ServiceConfiguration.cscfg and ServiceDefinition.csdef in the bin\Release folder after the package command is completed.
How can i achieve the same from an MSBuild command line ? I have tried
msbuild.exe
/p:DeployTarget=Package
/p:DeployOnBuild=true
/p:AutomatedBuild=True
/p:configuration=release
/p:outdir="D:\Pub"
/p:targetprofile="Cloud"
/target:Publish
/p:SolutionDir=$/src/mysln/ WorkerRole.ccproj
What i get is the command completes and i can see around 241 dll and the required files in the folder. Am i missing something in the command argument ? Please advice
Edit : Also refered the official docs , could'nt find anything
Edit 2 : Looks like i can get the packages generated. Now the problem is doing this in VSTS. The build is failing with " projectfile="*Undefined*Obfuscator\Maps\
Basically the solution path is becoming as undefined
Edit 3 : Here's the error message when i try to build only the CloudServiceProj
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(5165,5): Error MSB3073: The command "if "Release" == "Debug" goto :exit
"*Undefined*Obfuscator\Tool\CO" projectfile="*Undefined*Obfuscator\Maps
The undefined is working fine locally , since it has the $(SolutionDir) variable in VS. Not sure how do i handle it here
Update
Here's the msbuild that am using
Update 4
I tried building the solution directly as suggested, but it has some .NET CORE as well as .NET Framework projects and i am getting this error
C:\Program Files\dotnet\sdk\2.2.105\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(163,11): Error MSB4006: There is a circular dependency in the target dependency graph involving target "Publish"..
What i get is the command completes and i can see around 241 dll and the required files in the folder. Am i missing something in the command argument ?
For this question, you can try to change the argument /p:outdir="D:\Pub" to /p:PublishDir="D:\Pub". That because the argument outdir is used to stored the output files not the publish files, it contains the build output of the projects (including the reference project). That the reason why there are around 241 dll and the required files in the folder.
As I test, if I change the argument to PublishDir, it works fine:
For the second question, I am not familiar with Azure Cloud Service, as I know about MSBuild/Visual Studio, we should build the "main" project instead of the reference project, so you can try to build the AzureCloudService.ccproj or build the solution file .sln.
Besides, when we build the project/solution, we do not need specify the solution folder, just specify the project file or solution directly:
msbuild.exe "TheRelativePathForYourSolutionInRepos.sln" /t:Publish /p:DeployOnBuild=true /p:AutomatedBuild=True /p:configuration=release /p:TargetProfile=Cloud /p:PublishDir="D:\Pub"
If above not resolve your questions, please share your build error log in your question.
Update:
For the second part, I have a post build event which does some
obfuscation .
If you have use any Macros, like $(SolutionDir) in your build event, but build the project file, you will got that error. Because the project reference information exists in the solution information, we can't access it when we only build one project.
Try to replace all $(SolutionDir) with $(ProjectDir)..\
Update2:
Since you can build the .sln file on your local without any issue, you could also build the .sln file with Azure pipeline. As test, I could build the .sln file in the Azure pipeline:
Besides, if you have replace $(SolutionDir) with $(ProjectDir)..\, how do you still get the error Undefined? Try to double check you build event, or you can share it in the question.
Hope this helps.

Visual Studio Extension build failing with Error VSSDK1077: Unable to locate the extensions directory. "Value cannot be null

I have configured a TFS(2017) build pipeline to compile a VS extension with debug mode for a specific requirement which require .pdb files.
The build solution task fails for "debug" configuration with below error, however same pipeline works for the release configuration.
I have tried the approach mentioned in the following discussion as well, howewer it doesn't resolve my issue.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/fd220999-5761-475a-bf86-98dff6b35218/unable-to-compile-vsix-project-that-is-a-part-of-my-solution-using-amd64-msbuild-from-vs2015?forum=msbuild
Appreciate if someone can help me to resolve this issue.
Following is the build configuration used for the Build Solution task:
Following build variables are used to configure build parameters.
Build Error message:
packages\Microsoft.VSSDK.BuildTools.15.1.192\tools\VSSDK\Microsoft.VsSDK.targets
(633, 5)
packages\Microsoft.VSSDK.BuildTools.15.1.192\tools\VSSDK\Microsoft.VsSDK.targets(633,5):
Error VSSDK1077: Unable to locate the extensions directory. "Value
cannot be null. Parameter name: path1". Process 'msbuild.exe' exited
with code '1'.
Update your Microsoft.VSSDK.BuildTools NuGet package to latest version 15.9.3032, just in case it is a problem already solved.
Release configurations can also generate PDB files (Project properties, Build tab, Advanced...button, Output > Debugging information). So, if the Release configuration works for you, you can keep using it while also generating a pdb file with full debug information.
The error is happening when, once compiled correctly, the generated VSIX output file is going to be deployed to the folder for extensions of the experimental VS instance, which is a required step to debug the VSIX file. A possible explanation of the different behavior for Debug/Release configurations is that maybe your .csproj specifies <DeployExtension>False</DeployExtension> for the Release configuration. By default, if not set, that property is set to true in the Microsoft.VsSDK.targets file:
<DeployExtension Condition="'$(DeployExtension)' == ''">true</DeployExtension>
Since likely you don't need to deploy the VSIX to the VS experimental instance when building on a build server (because you are not going to debug it), you can set that property to False to skip the deployment. This can be done with a 3rd build configuration (ex: "DebugBuildServer"), for which you specify DeployExtension to False in the .csproj file, or sticking to two build configurations but passing the /p:DeployExtension=false in the MSBuild arguments of the Visual Studio Build task of your build pipeline.

MSBuild - Can I build for a Build Configuration without a solution?

I want to build a project with a particular named Build Configuration, let's call it Conf-A.
This is running as an MSBuild step on TeamCity. When the build runs, it spits out:
The OutputPath property is not set for project ... You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.
This project is part of a hulking great solution we load on our dev machines.
The error makes sense for my situation, since I'm building just the proj file, but I don't want to use the solution file since I'm trying break-up this monolithic app.
I want the build-server to treat this project as it's own component, even if for the moment it is part of a solution and has references to other projects (assemblies) in the solution.
Must I build this via a solution file?
I could potentially copy the solution file and prune off all the other projects that are not required, but that's more complexity.
(Maybe the error is a red-herring).
you dont need to build a sln. Its like the error says. You just havent specified a value for the variable OutputPath in your msbuild. You can add it to your files or you can pass it in at the cmd line - msbuild someproj.proj /p:OutputPath=C:\notallovermydrive

Building C# (Mono) Solution from GitHub with TeamCity on CentOS

I am trying to get TeamCity to do automated builds for me on CentOS, however if I create a runner type of 'MSBuild' I get the following error
Failed to start MSBuild.exe. Failed to find msbuild.exe at path: /usr/lib/mono/4.0/xbuild.exe
I tried a runner type of 'Visual Studio (sln)' setting Visual Studio to be 2012 and got the following error
No enabled compatible agents for this build configuration.
When I look at my Agent Requirements, I see:
Unmet requirements: DotNetFramework4.5_x86 exists
I honestly have no idea what could be wrong. Mono is up and running on this machine, as it is hosting a website built with Mono. Could somebody with a bit more experience let me know what I have done wrong please?
[EDIT]
I have just tried creating a symbolic link of where xbuild actually lives to where TeamCity wants it.
ln -s /usr/bin/xbuild /usr/lib/mono/4.0/xbuild.exe
I now am getting the following error in the Build log, so I am thinking it doesn't like symbolic links.
[MSBuild output] Cannot open assembly '/usr/lib/mono/4.0/xbuild.exe': File does not contain a valid CIL image.
I was able to get around this by adding an environment variable to the buildAgent.properties file on the build agent. Once you find that file add something like this in the Environment Variables section:
env.MSBuild=/usr/local/lib/mono/xbuild/12.0/bin/
I was doing this with ubuntu so that path might not be the same as what you were looking for.

MSBuild ResolveProjectReferences Error

My MSBuild build script executes fine on all the development machines, but fails to run on the build server, except for the Trunk build. Branches all fail with the following warnings indicating the source of the problem:
Target "ResolveProjectReferences":
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets (0,0):
warning : The referenced project '..\..\..\Class Library\
Company.BusinessModel\Company.BusinessModel.csproj' does not exist.
I can't understand why this error is even appearing - I have verified that (relative to the csproj being processed) the referenced project does exist. Copying (file copy) the checked out code to my local machine and running the script, the build completes as expected.
Is there anything obviously wrong here? Anything I can check to try and resolve this mystery?
EDIT:
I've tried running MSBuild against the project raising the build error in isolation, so it's not the rest of the solution which is the problem, just something about this specific .csproj file.
I actually found the problem. It's a bug in Visual Studio 2010 with path names totalling 259
http://support.microsoft.com/kb/2516078
Have you run msbuild in diag mode. That should give you some hints about the current path, and the relative path that MSBuild is trying to search.
msbuild myproj.msbuild /v:diag