我目前正在尝试编写一个应用程序,它将作为一个自动发布过程。在这个过程中,我需要构建和发布许多项。我能够成功地构建和发布web应用程序,但是,当发布网站时,我遇到了问题。
通过以下命令行执行,我能够成功完成所需的任务:
msbuild website.publishproj /p:deployOnbuild=true /p:PublishProfile="test.pubxml"我尝试通过使用构建库来执行此操作,但它失败了:
string projectFileNamepub = CurrentPublish.ExcaliburBuildPath;
Dictionary<string, string> GlobalPropertypub = new Dictionary<string, string>();
ProjectCollection pcpub = new ProjectCollection();
//pcpub.SkipEvaluation = true;
//GlobalPropertypub.Add("Configuration", "Release");
//GlobalPropertypub.Add("Platform", "x86");
GlobalPropertypub.Add("DeployOnBuild", "true");
GlobalPropertypub.Add("PublishProfile",CurrentPublish.ExcaliburPublishProfile);
//GlobalPropertypub.Add("VisualStudioVersion", "11.0");
BuildRequestData BuildRequestpub = new BuildRequestData(projectFileNamepub, GlobalPropertypub, null, new string[] { "Build" }, null);
BuildResult buildResultpub = BuildManager.DefaultBuildManager.Build(new BuildParameters(pcpub), BuildRequestpub);
if (buildResultpub.OverallResult == BuildResultCode.Success)
{
bsuccess = true;
txtOutput.Text = txtOutput.Text + "Publish Success \n";
}注释掉的属性是我尝试使用的属性,但没有一个成功。
我是不是做错了什么?在此之前,我已经使用它发布了另一个web应用程序,它成功地完成了。
此目标已成功完成:
_CheckForInvalidConfigurationAndPlatform然后,它在构建时失败。
发布于 2016-03-31 02:11:25
如果您以这种方式创建构建参数,则可以在控制台上显示构建输出:
var buildParameters = new BuildParameters(pc)
{
Loggers = new List<Microsoft.Build.Framework.ILogger> { new ConsoleLogger() }
};当我这样做时,我看到了以下错误:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(4353,5): error MSB4127: The "GetPublishingLocalizedString" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.Tasks.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Web.Publishing.Tasks.GetPublishingLocalizedString' to type 'Microsoft.Build.Framework.ITask'.我搜索了error MSB4127,在这里找到了答案:MSBuild "GenerateFakes" Error MSB4127, MSB4060
我已经指定了VisualStudioVersion。我只需将C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe.config中的<runtime>部分添加到我的App.config中,构建和发布就可以工作了。
https://stackoverflow.com/questions/27032940
复制相似问题