从MSBuild的解决方案发布一个Web项目 [英] Publish one web project from solution with msbuild

查看:4597
本文介绍了从MSBuild的解决方案发布一个Web项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图部署Web项目之一在我的解决方案的服务器。我使用的MSBuild上的TeamCity像这样:

 的MSBuild MySolution.sln /吨:网址:重建/ P:DeployOnBuild = TRUE /电话号码:PublishProfile =督促... 

然而,当我运行它,依然的MSBuild试图建立我的WebService 的项目,即使我的网​​站项目不依赖于它(但它不依赖于一个服务项目也在溶液)。如何只发布一个项目,又名刚网​​站



我也试图建立使用项目文件

 的MSBuild网站/ WebSite.csproj / p:DeployOnBuild =真... 

但随后抱怨说,它无法恢复包:

  [7点47分17秒] WebSite\WebSite.csproj.teamcity:建立目标:构建
[7点47分17秒] [WebSite\WebSite.csproj.teamcity] RestorePackages
[07 :47:17] [RestorePackages] EXEC
[7点47分十七秒] [执行] C:\TeamCity\buildAgent\work\cab8a3d752df3a51\.nuget\NuGet.targets(90,15 ):错误MSB4064:该LogStandardErrorAsError参数不被EXEC的任务的支持。验证存在于任务的参数,而且它是一个可设置的公共实例属性。
[7时47分17秒] [执行] C:\TeamCity\buildAgent\work\cab8a3d752df3a51\.nuget\NuGet.targets(89,9):错误MSB4063:该执行任务无法使用其输入参数被初始化。
[7时47分17秒] [WebSite\WebSite.csproj.teamcity]项目WebSite\WebSite.csproj.teamcity失败。

当我禁用的NuGet包还原,CoreCompile(CSC)失败,错误我从来没有听说过的和不应该发生的事情:

  [7点54分43秒] WebSite\WebSite.csproj.teamcity:建立目标:构建(13S)
[7点54分55秒] [WebSite\WebSite.csproj.teamcity] CoreCompile
[7点54分55秒] [CoreCompile]中信建投
[7点54分56秒] [中信建投] Areas\Api\Services\TripService.cs(19,104):错误CS0241:默认参数指定不允许
[7点54分56秒] [中信建投] Helpers\StatisticsUtility。 CS(11,35):错误CS1031:类型预期的
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(11,53):错误CS1002:;预计
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(16,28):错误CS1519:无效令牌(类,结构或接口成员声明
[07 :54:56] [中信建投] Helpers\StatisticsUtility.cs(16,37):错误CS1519:无效令牌','类,结构或接口成员声明
[7点54分56秒] [CSC ] Helpers\StatisticsUtility.cs(17,27):错误CS1519:无效令牌(类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs (17,32):错误CS1519:无效令牌')'类,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(23,17):错误CS1519:无效令牌'的'类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(23,26):错误CS1519:无效令牌'< ='类,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(23,45):错误CS1519:无效令牌' - '类,结构,或接口成员声明
[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(23,51):错误CS1519:类无效令牌++,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(24,34):错误CS0270:不能在变量声明(尝试一个新的表达初始化)
指定数组大小[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(24,37):错误CS1519:无效令牌'=='类,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(24,51):错误CS1519:无效令牌')'类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\ StatisticsUtility.cs(24,63):错误CS1519:无效令牌'++类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(25, 41):错误CS1519:无效令牌'>'类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(25,53):错误CS1519:在类,结构或接口成员声明
[7时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(27,36)无效令牌')':错误CS1519:无效令牌'='类,结构或接口成员声明
[7时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(27,48):错误CS1519:无效令牌';'类,结构或接口成员声明
[7点五十四分56秒] [中信建投] Helpers\StatisticsUtility.cs(28,36):错误CS1519:类无效令牌'=',结构或接口成员声明
[07: 54:56] [中信建投] Helpers\StatisticsUtility.cs(29,37):错误CS1519:类无效令牌'=',结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(29,48):错误CS0270:数组大小不能在变量声明(尝试一个新的表达初始化)
[7点54分56秒]中指定[中信建投] Helpers\\ \\StatisticsUtility.cs(29,50):错误CS1519:无效令牌';'类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(30, 33):错误CS1519:无效令牌'='类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(30,44):错误CS0270:数组大小不能在变量声明(尝试一个新的表达初始化)
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(30,50)中规定:错误CS1519:无效令牌 ;'类,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\StatisticsUtility.cs(32,21):错误CS0116:命名空间并不直接包含成员如字段或方法
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(35,50):错误CS1518:预期类,委托,枚举,接口或结构
[07:54 :56] [中信建投] Helpers\StatisticsUtility.cs(38,21):错误CS0116:命名空间并不直接包含成员如字段或方法
[7点54分56秒] [中信建投] Helpers\ StatisticsUtility.cs(40,50):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\StatisticsUtility.cs(42,21):错误CS1022:类型或命名空间的定义,或预期的
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(8,59)文件结束-:错误CS1031:类型预期的
[ 7时54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(8,80):错误CS1002:;预计
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(10,55):错误CS1519:无效令牌(类,结构或接口成员声明
[07 :54:56] [中信建投] Helpers\UrlHelperExtensions.cs(10,60):错误CS1520:类,结构或接口方法必须有一个返回类型
[7点54分56秒] [中信建投]助手\UrlHelperExtensions.cs(10,82):错误CS1002:;预计
[七点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(13,23):错误CS1518:预期类,委托枚举,接口或结构
[7时54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(15,60):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(18,23):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(20,25):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(23,28 ):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(26,28):错误CS1518:预期类,委托枚举,接口或结构
[7时54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(29,24):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(29,84):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(32,28):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(35,9 ):错误CS1022:类型或命名空间的定义,或预期的
[7时54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(23,26)文件结束-:错误CS0101:命名空间'< ;全局命名空间>'已经包含了一个定义''
[七时54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(26,26):错误CS0101:命名空间?<全局命名空间> 已经包含了一个定义,'
[7时54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(29,22):错误CS0101:命名空间?<全局命名空间>'已经包含了'?'定义
[7点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(29,83):错误CS0101:命名空间'<全局命名空间>'已经包含了'的定义? '
[七点54分56秒] [中信建投] Helpers\UrlHelperExtensions.cs(32,26):错误CS0101:命名空间'<全局命名空间>'已经包含了一个定义''$ b $? b〔7时54分56秒] [中信建投] Controllers\SessionController.cs(13,51):错误CS0241:默认参数指定不允许
[7点54分56秒] [中信建投] Helpers\JsonNetResult的.cs(13,44):错误CS1031:类型预期的
[7点54分56秒] [中信建投] Helpers\JsonNetResult.cs(13,72):错误CS1041:标识符预期,对象是一个关键字
[7时54分56秒] [中信建投] Helpers\JsonNetResult.cs(13,91):错误CS1002:;预计
[7点54分56秒] [中信建投] Helpers\JsonNetResult.cs(16,38):错误CS1519:无效令牌'='类,结构或接口成员声明
[07 :54:56] [中信建投] Helpers\JsonNetResult.cs(16,59):错误CS1519:无效令牌';'类,结构或接口成员声明
[7点54分56秒] [CSC ] Helpers\JsonNetResult.cs(17,64):错误CS1519:无效令牌'='类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\JsonNetResult.cs (17,90):错误CS1519:无效令牌';'类,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\JsonNetResult.cs(18,32):错误CS1519:无效令牌'='类,结构或接口成员声明
[七时54分56秒] [中信建投] Helpers\JsonNetResult.cs(18,46):错误CS1519:无效令牌;在类,结构或接口成员声明
[7时54分56秒] [中信建投] Helpers\JsonNetResult.cs(19,33):错误CS1519:无效令牌';'类,结构或接口成员声明
[7点54分56秒] [中信建投] Helpers\JsonNetResult.cs(22,23):错误CS1518:预期类,委托,枚举,接口或结构
[07:54 :56] [中信建投] Helpers\JsonNetResult.cs(25,37):错误CS1518:预期类,委托,枚举,接口或结构
[七时54分56秒] [中信建投] Helpers\JsonNetResult的.cs(32,23):错误CS1518:预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\JsonNetResult.cs(35,37):错误CS1518 :预期类,委托,枚举,接口或结构
[7点54分56秒] [中信建投] Helpers\JsonNetResult.cs(40,9):错误CS1022:类型或命名空间的定义,或结束-file预期的
[7点54分56秒] [中信建投] Mailers\ITripMailer.cs(13,132):错误CS0241:默认参数指定不允许
[7点54分56秒] [中信建投] Mailers\TripMailer.cs(54,85):错误CS0241:默认参数指定不允许
[7时54分56秒] [中信建投] Services\Impl\AuthorizationService.cs(12,70 ):错误CS0241:默认参数指定不允许
[7点54分56秒] [中信建投] Services\Impl\AuthorizationService.cs(43,77):错误CS0241:默认参数指定不允许
〔7时54分56秒] [WebSite\WebSite.csproj.teamcity]项目WebSite\WebSite.csproj.teamcity失败。


解决方案

我的博客上讲述这个在的 http://sedodream.com/2013/03/06/HowToPublishOneWebProjectFromASolution.aspx 几个月前。我在这里复制的细节,以及,见下文






今天在twitter上的@nunofcosta 问我大概这个问题:我如何从一个包含许多解决方案发布一个web项目?



他是运行到的问题是,他是在命令行建设,并通过以下属性msbuild.exe。

  / p:DeployOnBuild = TRUE 
/ p:PublishProfile ='siteone - Web部署'
/ p:密码=%密码%

您可以在 HTTP了解更多关于如何自动化出版:// sedodream.com/2013/01/06/CommandLineWebProjectPublishing.aspx



当你通过这些属性来msbuild.exe它们被称为全局属性。这些性能是困难的覆盖和被传递给每一个建立项目。正因为如此,如果你有多个Web项目,在每一个web项目建成它在同一组属性通过一个解决方案。正因为如此,当每个项目是建立在发布过程该项目将启动,它会希望找到一个名为 siteone - 网页Deploy.pubxml 文件夹中的* Properties\PublishProfiles *。如果文件不存在操作可能失败



注意:如果您有兴趣使用这种技术的精心策划出版看到我的评论在<一个HREF =htt​​p://stackoverflow.com/a/14231729/105999> http://stackoverflow.com/a/14231729/105999 才这样做的。



那么,如何才能解决这个问题?



让我们来看看一个样本(见下面的链接)。我有一个解决方案, PublishOnlyOne ,具有以下的项目。




  1. ProjA

  2. ProjB



ProjA已命名发布配置文件' siteone - Web部署,ProjB不。当试图发​​布此您可以尝试下面的命令行

  msbuild.exe PublishOnlyOne.sln / P:DeployOnBuild =真/电话号码:PublishProfile ='siteone  -  Web部署/ p:密码=%密码%

见样品中发布 - sln.cmd。



如果你这样做,当它的时间ProjB建会失败,因为没有 siteone - Web部署个人资料该项目。正因为如此,我们无法通过DeployOnBuild。相反,这里就是我们需要做的。




  1. 编辑ProjA.csproj定义将有条件地设置DeployOnBuild另一个属性

  2. 从命令行传递该属性



我编辑ProjA和导入语句之前增加了以下属性组该文件的.csproj

 <&的PropertyGroup GT; 
< D​​eployOnBuild条件='$(DeployProjA)'=''!> $(DeployProjA)LT; / DeployOnBuild>
< /&的PropertyGroup GT;



在这里,您可以看到DeployOnBuild设置为只要它不是空的任何值DeployProjA是。现在,修改后的命令是:



  msbuild.exe PublishOnlyOne.sln / P:DeployProjA = TRUE / ​​P:PublishProfile ='siteone  - Web部署/ p:密码=%密码%

下面强似DeployOnBuild,我通过在DeployProjA然后将设置DeployOnBuild。由于DeployOnBuild并没有传递给ProjB它不会尝试发布。



您可以在这里找到的 https://github.com/sayedihashimi/sayed-samples/tree/master/PublishOnlyOne


I'm trying to deploy one of the web projects in my solution to a server. I am using msbuild on TeamCity like so:

msbuild MySolution.sln /t:WebSite:Rebuild /p:DeployOnBuild=True /p:PublishProfile=Prod ...

However, when I run it, msbuild still tries to build my WebService project, even though my WebSite project does not depend on it (but it does depend on a Services project also in the solution). How do only publish one project, aka just WebSite?

I have also tried building the project file using

msbuild WebSite/WebSite.csproj /p:DeployOnBuild=True ...

but it then complains that it can't restore packages:

[07:47:17]WebSite\WebSite.csproj.teamcity: Build target: Build
[07:47:17][WebSite\WebSite.csproj.teamcity] RestorePackages
[07:47:17][RestorePackages] Exec
[07:47:17][Exec] C:\TeamCity\buildAgent\work\cab8a3d752df3a51\.nuget\NuGet.targets(90, 15): error MSB4064: The "LogStandardErrorAsError" parameter is not supported by the "Exec" task. Verify the parameter exists on the task, and it is a settable public instance property.
[07:47:17][Exec] C:\TeamCity\buildAgent\work\cab8a3d752df3a51\.nuget\NuGet.targets(89, 9): error MSB4063: The "Exec" task could not be initialized with its input parameters. 
[07:47:17][WebSite\WebSite.csproj.teamcity] Project WebSite\WebSite.csproj.teamcity failed.

When I disable NuGet Package Restore, CoreCompile (Csc) fails with errors I've never heard of and shouldn't be happening:

[07:54:43]WebSite\WebSite.csproj.teamcity: Build target: Build (13s)
[07:54:55][WebSite\WebSite.csproj.teamcity] CoreCompile
[07:54:55][CoreCompile] Csc
[07:54:56][Csc] Areas\Api\Services\TripService.cs(19, 104): error CS0241: Default parameter specifiers are not permitted
[07:54:56][Csc] Helpers\StatisticsUtility.cs(11, 35): error CS1031: Type expected
[07:54:56][Csc] Helpers\StatisticsUtility.cs(11, 53): error CS1002: ; expected
[07:54:56][Csc] Helpers\StatisticsUtility.cs(16, 28): error CS1519: Invalid token '(' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(16, 37): error CS1519: Invalid token ',' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(17, 27): error CS1519: Invalid token '(' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(17, 32): error CS1519: Invalid token ')' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(23, 17): error CS1519: Invalid token 'for' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(23, 26): error CS1519: Invalid token '<=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(23, 45): error CS1519: Invalid token '-' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(23, 51): error CS1519: Invalid token '++' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(24, 34): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
[07:54:56][Csc] Helpers\StatisticsUtility.cs(24, 37): error CS1519: Invalid token '==' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(24, 51): error CS1519: Invalid token ')' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(24, 63): error CS1519: Invalid token '++' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(25, 41): error CS1519: Invalid token '>' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(25, 53): error CS1519: Invalid token ')' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(27, 36): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(27, 48): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(28, 36): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(29, 37): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(29, 48): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
[07:54:56][Csc] Helpers\StatisticsUtility.cs(29, 50): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(30, 33): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(30, 44): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)
[07:54:56][Csc] Helpers\StatisticsUtility.cs(30, 50): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\StatisticsUtility.cs(32, 21): error CS0116: A namespace does not directly contain members such as fields or methods
[07:54:56][Csc] Helpers\StatisticsUtility.cs(35, 50): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\StatisticsUtility.cs(38, 21): error CS0116: A namespace does not directly contain members such as fields or methods
[07:54:56][Csc] Helpers\StatisticsUtility.cs(40, 50): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\StatisticsUtility.cs(42, 21): error CS1022: Type or namespace definition, or end-of-file expected
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(8, 59): error CS1031: Type expected
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(8, 80): error CS1002: ; expected
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(10, 55): error CS1519: Invalid token '(' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(10, 60): error CS1520: Class, struct, or interface method must have a return type
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(10, 82): error CS1002: ; expected
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(13, 23): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(15, 60): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(18, 23): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(20, 25): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(23, 28): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(26, 28): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(29, 24): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(29, 84): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(32, 28): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(35, 9): error CS1022: Type or namespace definition, or end-of-file expected
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(23, 26): error CS0101: The namespace '<global namespace>' already contains a definition for '?'
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(26, 26): error CS0101: The namespace '<global namespace>' already contains a definition for '?'
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(29, 22): error CS0101: The namespace '<global namespace>' already contains a definition for '?'
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(29, 83): error CS0101: The namespace '<global namespace>' already contains a definition for '?'
[07:54:56][Csc] Helpers\UrlHelperExtensions.cs(32, 26): error CS0101: The namespace '<global namespace>' already contains a definition for '?'
[07:54:56][Csc] Controllers\SessionController.cs(13, 51): error CS0241: Default parameter specifiers are not permitted
[07:54:56][Csc] Helpers\JsonNetResult.cs(13, 44): error CS1031: Type expected
[07:54:56][Csc] Helpers\JsonNetResult.cs(13, 72): error CS1041: Identifier expected, 'object' is a keyword
[07:54:56][Csc] Helpers\JsonNetResult.cs(13, 91): error CS1002: ; expected
[07:54:56][Csc] Helpers\JsonNetResult.cs(16, 38): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(16, 59): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(17, 64): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(17, 90): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(18, 32): error CS1519: Invalid token '=' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(18, 46): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(19, 33): error CS1519: Invalid token ';' in class, struct, or interface member declaration
[07:54:56][Csc] Helpers\JsonNetResult.cs(22, 23): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\JsonNetResult.cs(25, 37): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\JsonNetResult.cs(32, 23): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\JsonNetResult.cs(35, 37): error CS1518: Expected class, delegate, enum, interface, or struct
[07:54:56][Csc] Helpers\JsonNetResult.cs(40, 9): error CS1022: Type or namespace definition, or end-of-file expected
[07:54:56][Csc] Mailers\ITripMailer.cs(13, 132): error CS0241: Default parameter specifiers are not permitted
[07:54:56][Csc] Mailers\TripMailer.cs(54, 85): error CS0241: Default parameter specifiers are not permitted
[07:54:56][Csc] Services\Impl\AuthorizationService.cs(12, 70): error CS0241: Default parameter specifiers are not permitted
[07:54:56][Csc] Services\Impl\AuthorizationService.cs(43, 77): error CS0241: Default parameter specifiers are not permitted
[07:54:56][WebSite\WebSite.csproj.teamcity] Project WebSite\WebSite.csproj.teamcity failed.

解决方案

I blogged about this at http://sedodream.com/2013/03/06/HowToPublishOneWebProjectFromASolution.aspx a few months back. I've copied the details here as well, see below.


Today on twitter @nunofcosta asked me roughly the question "How do I publish one web project from a solution that contains many?"

The issue that he is running into is that he is building from the command line and passing the following properties to msbuild.exe.

/p:DeployOnBuild=true
/p:PublishProfile='siteone - Web Deploy'
/p:Password=%password%

You can read more about how to automate publishing at http://sedodream.com/2013/01/06/CommandLineWebProjectPublishing.aspx.

When you pass these properties to msbuild.exe they are known as global properties. These properties are difficult to override and are passed to every project that is built. Because of this if you have a solution with multiple web projects, when each web project is built it is passed in the same set of properties. Because of this when each project is built the publish process for that project will start and it will expect to find a file named siteone – Web Deploy.pubxml in the folder *Properties\PublishProfiles*. If the file doesn’t exist the operation may fail.

Note: If you are interested in using this technique for an orchestrated publish see my comments at http://stackoverflow.com/a/14231729/105999 before doing so.

So how can we resolve this?

Let’s take a look at a sample (see links below). I have a solution, PublishOnlyOne, with the following projects.

  1. ProjA
  2. ProjB

ProjA has a publish profile named ‘siteone – Web Deploy’, ProjB does not. When trying to publish this you may try the following command line.

msbuild.exe PublishOnlyOne.sln /p:DeployOnBuild=true /p:PublishProfile=’siteone – Web Deploy’ /p:Password=%password%

See publish-sln.cmd in the samples.

If you do this, when its time for ProjB to build it will fail because there’s no siteone – Web Deploy profile for that project. Because of this, we cannot pass DeployOnBuild. Instead here is what we need to do.

  1. Edit ProjA.csproj to define another property which will conditionally set DeployOnBuild
  2. From the command line pass in that property

I edited ProjA and added the following property group before the Import statements in the .csproj file.

<PropertyGroup>
<DeployOnBuild Condition=" '$(DeployProjA)'!='' ">$(DeployProjA)</DeployOnBuild>
</PropertyGroup>

Here you can see that DeployOnBuild is set to whatever value DeployProjA is as long as it’s not empty. Now the revised command is:

msbuild.exe PublishOnlyOne.sln /p:DeployProjA=true /p:PublishProfile=’siteone – Web Deploy’ /p:Password=%password%

Here instead of passing DeployOnBuild, I pass in DeployProjA which will then set DeployOnBuild. Since DeployOnBuild wasn’t passed to ProjB it will not attempt to publish.

You can find the complete sample at https://github.com/sayedihashimi/sayed-samples/tree/master/PublishOnlyOne.

这篇关于从MSBuild的解决方案发布一个Web项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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