MSBUILD : error MSB1008: Only one project can be specified in teamcity - msbuild

I am trying to run MSBuild with TeamCity.
I have a batch file and I pass into it parameters and the build works. When I try to run through TeamCity I get the error below
[13:24:46][MSBuild output] Start MSBuild...
[13:24:46][MSBuild output] 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe'
'"#C:\TeamCity\buildAgent\work\999585556854a516\Build\Default.msbuild.teamcity.msbuild.tcargs" C:\TeamCity\buildAgent\work\999585556854a516\Build\Default.msbuild.teamcity'
[13:24:46][MSBuild output] working dir = 'C:\TeamCity\buildAgent\work\999585556854a516'
[13:24:46][MSBuild output] Microsoft (R) Build Engine Version 4.0.30319.1
[13:24:46][MSBuild output] [Microsoft .NET Framework, Version 4.0.30319.296]
[13:24:46][MSBuild output] Copyright (C) Microsoft Corporation 2007. All rights reserved.
[13:24:46][MSBuild output]
[13:24:46][MSBuild output] MSBUILD : error MSB1008: Only one project can be specified.
[13:24:46][MSBuild output] Switch: C:\TeamCity\buildAgent\work\999585556854a516\Build\Default.msbuild.teamcity
[13:24:46][MSBuild output]
[13:24:46][MSBuild output] For switch syntax, type "MSBuild /help"
In TeamCity my command line parameters field looks like
Configuration=Debug;DeployPath=E:\websites\umbraco\mysite;Environment=Dev;
I did search on StackOverflow and people having similar issues mention ensuring no spaces in commandline parameters also my sln and proj files / pages do not have spaces.
As I said when I run a batch file with those parameters it all works, however, TeamCity fails.

I managed to reproduce the error in the command line: apparently the file contents for Default.msbuild.teamcity.msbuild.tcargs need to be:
/p:Configuration=Debug;DeployPath=E:\websites\umbraco\mysite;Environment=Dev;
instead of:
Configuration=Debug;DeployPath=E:\websites\umbraco\mysite;Environment=Dev;

Related

Show project indexes when building VS Solution with MSBuild

When building a Soultion with Visual Studio, each line is marked with an index that corresponds to a particular procees project:
Build started...
1>------ Build started: Project: rootProject, Configuration: Debug Win32 ------
2>------ Build started: Project: SkypeDLAPI_IDL, Configuration: Debug Win32 ------
3>------ Build started: Project: NLHCLib, Configuration: Debug Win32 ------
4>------ Build started: Project: AprDLAPI_IDL, Configuration: Debug Win32 ------
5>------ Build started: Project: DLServiceCMN, Configuration: Debug Win32 ------
6>------ Build started: Project: SkypeProfile, Configuration: Debug Win32 ------
7>------ Build started: Project: DLRes, Configuration: Release Win32 ------
8>------ Build started: Project: DLMessages, Configuration: Debug Win32 ------
2>Processing .\RpcNetworkLock.idl
2>RpcNetworkLock.idl
6>spAccounts.cpp
6>spConversations.cpp
However, when I run MSBuild.exe
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\msbuild\Current\Bin\amd64\MSBuild.exe"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\msbuild\Current\Bin\amd64\MSBuild.exe" "DeviceLock_vs2019.sln" /p:PreferredToolArchitecture=x64 /p:Configuration="Debug" /p:Platform="Win32" /t:build /maxcpucount:6 /verbosity:Minimal /fileLogger1 /fileloggerparameters1:ErrorsOnly;LogFile="C:/Users/sergey.kolesnik/dev/repos/DLP/main/src/all.log";Verbosity=Minimal;Encoding=ASCII; /fileLogger2 /fileloggerparameters2:ErrorsOnly;Append;LogFile="C:/Users/sergey.kolesnik/dev/repos/DLP/main/src/\all_Debug_Win32.err";Encoding=ASCII; /filelogger4 /fileloggerparameters4:LogFile="C:/Users/sergey.kolesnik/dev/repos/DLP/main/src/\all_Debug_Win32.det";Verbosity=normal;ShowCommandLine=no /ds
I don't get such formating. Lines are not indexed and it is very hard to understand which project a processed source file belongs to:
FileTypeDetector_vs2019.vcxproj -> C:\Users\sergey.kolesnik\dev\repos\DLP\main\src\Out_2019\x86\Debug\FileTypeDetecto
r\FileTypeDetector.lib
ElasticClient_vs2019.vcxproj -> C:\Users\sergey.kolesnik\dev\repos\DLP\main\src\Out_2019\x86\Debug\ElasticClient\Elas
ticClient.lib
RemoteInstall_vs2019.vcxproj -> C:\Users\sergey.kolesnik\dev\repos\DLP\main\src\Out_2019\x86\Debug\RemoteInstall\Remo
teInstall.lib
TextUtils_vs2019.vcxproj -> C:\Users\sergey.kolesnik\dev\repos\DLP\main\src\Out_2019\x86\Debug\TextUtils\TextUtils.li
b
AlertSenderSmtp.cpp
FontGetter.cpp
PdfShadower.cpp
PrinterEnumCallbacks.cpp
PrinterHlp.cpp
EventLog.cpp
PrinterHook.cpp
netresident.cpp
AuditRecord.cpp
PrinterNameCache.cpp
RemoteDataProcess.cpp
PrinterProcessor.cpp
hooks_srv_utils.cpp
hooks_utils.cpp
ShadowPdfMerger.cpp
iphone_cfbinary.cpp
ClipboardData.cpp
settings.cpp
ClipboardDevice.cpp
ClipboardResCache.cpp
Are there any CLI parameters for MSBuild.exe that would make the logging output like when a Solution is built with Visual Studio?
Is there an option to print a list of failed projects at the end?
The 'index' is a 'project key'. Project keys are generated per build and within a build are unique per project. (See related "Do the 1>, 2>, 3> symbols in msbuild output stand for threads?")
There doesn't seem to be a documented switch to enable showing the project keys.
However I did some quick tests that are summarized in the following table:
Cmd
OS
Project Ids in the Log?
MSBuild version
msbuild
Windows
No
17.3
dotnet msbuild
Windows
Yes
17.3
msbuild
macOS
Yes
16.10
dotnet msbuild
macOS
Yes
16.10
This shows that a work-around is to run MSBuild via the dotnet command. This doesn't require any changes in your code. The dotnet tool is just a host for the MSBuild engine. The same is true of Visual Studio (devenv.exe). As hosts for MSBuild, dotnet and devenv are enabling the Project key in the logging.
MSBuild will list all warnings and errors at the end of the log but there is no option to generate a list of the failed projects.
The summary line that appears in the Visual Studio build output (like the following example) is generated by Visual Studio and doesn't come from MSBuild.
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

devenv build fails for WPF application when invoked with nuget restore with msbuild /restore

I am using msbuild /restore to retore the packages and then invoked devenv to build the solution. The commands are included in a batch file and this file is integrated to CI pipeline. The batch commands are as shown below.
_
msbuild MySolution.sln -t:Restore
"%VS160COMNTOOLS%..\IDE\devenv" "MySolution.sln" /build "%Build%|x64" /out MySolution.log
if errorlevel 1 goto :failed_
'MySolution.sln' includes two projects- a library project and a WPF application. The packages referenced in the projects are specified in a Packages.props file.
The build results are inconsistent. Sometimes it fails with following errors.
CSC : error CS2001: Source file
'\obj\DDLStyleEditor\Views\ElementGroupView.g.cs' could not be found.
CSC : error CS2001: Source file
'\obj\DDLStyleEditor\Views\OptionsView.g.cs' could not be found. CSC :
error CS2001: Source file
'\obj\DDLStyleEditor\Views\PropertiesView.g.cs' could not be found.
CSC : error CS2001: Source file
'\obj\DDLStyleEditor\Views\MainView.g.cs' could not be found.
It works fine with VS2019, the packages are properly restored and the solution build successfully. Then why does it fail with batch file??. Please help.

Error compile Visual Studio 2019 Project dll with MSBuild 2019, obfuscating with Eazfuscator NET 2018.2 in TeamCity 2020.2.2

I have this error when TeamCity Build Step compile with obfuscating a Visual Studio dll Project with MSBuild:
EXEC: error: Error occurred during processing of input file '.dll' -> Cannot load file or assembly 'zx_2cba06c4237a413ea1e8116e71ad61dc, PublicKeyToken = 6205972ab2f0fc68' or one of its dependencies. The system cannot find the specified file. C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets (5473,5): error MSB3073: The command "if /I "Release" == "Release" "C:\Program Files (x86)\Eazfuscator.NET\Eazfuscator.NET.exe" "E:\Builds\MyDll\bin\Release\MyDll.dll" --msbuild-project-path "E:\Builds\MyDll\MyDll.csproj" --msbuild-project-configuration "Release" --msbuild-project-platform "AnyCPU" --msbuild-solution-path "*Undefined*" -n --newline-flush -v 2018.2" exit with code 1.
Eazfuscator-.NET-2018.2.2 is not compatible with MSBuild 2019, the solution is use Eazfuscator-.NET-2019.1 as minimun version.

How to build sonarscanner ,getting "MSbuild.exe is not recognize as internal and external command"?

I have installed Msbuild along with studio2017 but while building sonarscanner the msbuild.exe not found error thrown.

MSBuild fails with an error in the "AL" task with error code AL1019

We are currently having problems while compiling a solution with MSBuild. The build fails randomly on the resource linking step inside the task "AL" which executes the "AL.exe" linker.
ALINK : error AL1019: Metadata failure while creating assembly -- The volume for a file has been externally altered so that the opened file is no longer valid.
The build log shows the following execution flow.
4>Target "GenerateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\source\MyProject.csproj" (target "CreateSatelliteAssemblies" depends on it):
4>Building target "GenerateSatelliteAssemblies" completely.
4>Output file "obj\Debug\de\MyProject.dll" does not exist.
4>Task "MakeDir"
4>Done executing task "MakeDir".
4>Task "AL"
4> C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\AL.exe /culture:de /out:obj\Debug\de\MyProject.resources.dll /template:obj\Debug\MyProject.dll /embed:obj\Debug\MyProject.SomeResource.de.resources
4> Microsoft (R) Assembly Linker version 14.0.0081.0
4> Copyright (C) Microsoft Corporation. All rights reserved.
4>
4>Done executing task "AL".
4>Done building target "GenerateSatelliteAssemblies" in project "MyProject.csproj".
4>Target "GenerateSatelliteAssemblies" in file "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets" from project "C:\source\MyProject.csproj" (target "CreateSatelliteAssemblies" depends on it):
4>Building target "GenerateSatelliteAssemblies" completely.
4>Output file "obj\Debug\en\MyProject.resources.dll" does not exist.
4>Task "MakeDir"
4>Done executing task "MakeDir".
4>Task "AL"
4> C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\AL.exe /culture:en /out:obj\Debug\en\MyProject.resources.dll /template:obj\Debug\MyProject.dll /embed:obj\Debug\MyProject.SomeResource.en.resources
4> Microsoft (R) Assembly Linker version 14.0.0081.0
4> Copyright (C) Microsoft Corporation. All rights reserved.
4>
4>ALINK : error AL1019: Metadata failure while creating assembly -- The volume for a file has been externally altered so that the opened file is no longer valid.
4> The command exited with code 1.
4>Done executing task "AL" -- FAILED.
4>Done building target "GenerateSatelliteAssemblies" in project "MyProject.csproj" -- FAILED.
To me it is completely unclear what is meant by the error code AL1019. The MSDN error code listing didn't help either.