MS编程以编程方式 [英] MS build Programatically

查看:340
本文介绍了MS编程以编程方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我使用C#.net以编程方式逐步构建一个Web应用程序,而不是通过命令行。

我在MSbuild看到不同的帖子但我没有一个人解释清楚。我使用下面的代码完成了一个示例,它只适用于.csproj类扩展,但不适用于.sln扩展名。





Can any one help me in building a web application using ms build programmatically step by step using C#.net but not through command line.
I am breaking my head seeing different posts on MSbuild but no one explained it clearly.I have done a sample using the below code, it is working only for .csproj kind of extension but not for .sln extension.


var project = projectCollection.LoadProject(solution_name);
          var fileLogger = new FileLogger();
          fileLogger.Parameters = @"logfile=" + logfile;
          projectCollection.RegisterLogger(fileLogger);

          bool result = project.Build();
          projectCollection.UnregisterAllLoggers();
          return result.ToString();</pre>









For。 sln它抛出如下错误

无法加载项目文件。根级别的数据无效。第2行,第1位。



请让我知道解决方案,我将感谢他们。





For .sln it is throwing an error as below
The project file could not be loaded. Data at the root level is invalid. Line 2, position 1.

Please let me know the solution for this and I will be thankful to them.

推荐答案

我在 msdn forum post [ ^ ]涵盖了这种情况
I found this discussion on an msdn forum post[^] which covers this scenario


这篇关于MS编程以编程方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆