0

I have compiled more then one solution file in process concepts.Some solution files are error occur.

Error is : MSBUILD : error MSB1008: Only one project can be specified.

I used following codes :

string installedPath=@"C:\Program Files (x86)\New folder";
string frameWork="2.0";
foreach (string projectPath in platformProjects)
{
 try
 {
   string MsbuildLocation = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319";
   Process process = new Process();
   process.StartInfo.FileName = MsbuildLocation + "\\MSBuild.exe";
   process.StartInfo.Arguments = "\"" + projectPath + "\"" + " /p:Configuration=Release /p:ReferencePath=\"" + installedPath + "Assemblies\\" + frameWork + "\" /p:OutDir="+ Environment.CurrentDirectory+"\\"+frameWork+"\\";
   process.StartInfo.CreateNoWindow = false;
   process.StartInfo.UseShellExecute = false;
   process.StartInfo.RedirectStandardOutput = true;
   process.Start();
   string errorlog = process.StandardOutput.ReadToEnd();
   process.WaitForExit();
 }
}

platformProjects is a string array.More then one .sln files.

Note: This error is came in some solution files.please tell me, How to Solve this error?

qxg
  • 6,190
  • 1
  • 23
  • 35
Ranjo
  • 11
  • 4
  • So you can reproduce the error by invoking `MSBUILS` directly? – qxg May 30 '16 at 10:52
  • Please tell me , How to Invoke MSBUILS directly? – Ranjo May 30 '16 at 11:02
  • http://stackoverflow.com/questions/16979137/msbuild-error-msb1008-only-one-project-can-be-specified-in-teamcity Write all **/p** argument as semicolon separated. – NeoAsh May 30 '16 at 11:13
  • Hi NeoAsh I write all /p argument as semicolon separated.source complied but all solution files same error came .. "\"" + projectPath + "\"" + " /p:Configuration=Release; /p:ReferencePath=\"" + installedPath + "Assemblies\\" + frameWork + "\" ;/p:OutDir="+ Environment.CurrentDirectory+"\\"+frameWork+"\\"; – Ranjo May 30 '16 at 11:32
  • NeoAsh Please tell me How to added semicolon separated? – Ranjo May 30 '16 at 11:33
  • Can you include an example of the strings in the platformProjects collection? – Max Young May 30 '16 at 12:54
  • PlatformProjects Collections : 1) C:\Users\ranj\oLocal\Chart\AxisLabels Customization Demo\CS\AxisLabelsCustomizationDemo_2010.sln – Ranjo May 31 '16 at 03:54
  • Instead of making your code hard to read and error prone, with all the escaping and backslashes, use System.IO.Path.Combine. Then, since you have spaces in your paths, you probably should use quotes around them. One of those two are going to be the problem. Also for added readability you're better of building the argument string in multiple statements instead of on one big line. Anyway, run your code under the debugger and inspect the value of FileName and Arguments and copy/paste that here. – stijn May 31 '16 at 07:28

0 Answers0