我正在尝试在DevOps中创建新的构建管道来构建网站。主要解决方案被用作源。它包含网站项目以及一个单独的单元测试项目。日志显示构建成功,但是发布部分没有运行。
对于构建解决方案步骤(使用Visual Studio Build),我传递了以下参数:
/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish /p:DeleteExistingFiles=true
我在本地计算机上使用msbuild运行了相同的构建参数
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin
将内容和相应文件放入publishUrl参数。
我也尝试使用默认模板而不进行任何修改。默认参数为/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
但在这种情况下没有构建任何程序包。
感觉就像完全忽略了传递的发布选项。
$(build.artifactstagingdirectory)
已解析为D:\a\1\a
。
“发布工件”步骤将产生以下日志:
[warning]Directory 'D:\a\1\a' is empty. Nothing will be added to build artifact 'drop'.
[section]Finishing: Publish Artifact: drop
任何人都对发生的事情有任何想法或建议?我想知道_PublishedWebsites文件夹是否存在/应该在哪里。我不想为此使用发布配置文件,因为我没有使用Azure来进行网站的实际部署。
谢谢!
msbuild输出
2019-03-29T15:51:41.2933271Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe" "D:\a\1\s\LoggingApi.sln" /nologo /nr:false /dl:CentralLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.148.1\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=89dd4c73-fcb3-42df-9dc2-04dd3a648e8f|SolutionDir=D:\a\1\s"*ForwardingLogger,"D:\a\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.148.1\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="D:\a\1\a\\" /p:DeployDefaultTarget=WebPublish /p:DeleteExistingFiles=true /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /p:_MSDeployUserAgent="VSTS_f901243b-a555-4171-87b9-2b1950d52707_build_3_0"
2019-03-29T15:51:41.3709460Z Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
2019-03-29T15:51:41.4083747Z Build started 3/29/2019 3:51:41 PM.
2019-03-29T15:51:41.5914885Z Project "D:\a\1\s\LoggingApi.sln" on node 1 (default targets).
2019-03-29T15:51:41.5931469Z ValidateSolutionConfiguration:
2019-03-29T15:51:41.5931540Z Building solution configuration "release|any cpu".
2019-03-29T15:51:41.9148684Z Project "D:\a\1\s\LoggingApi.sln" (1) is building "D:\a\1\s\LoggingApi\LoggingApi.csproj" (2) on node 1 (default targets).
2019-03-29T15:51:41.9148780Z PrepareForBuild:
2019-03-29T15:51:41.9148830Z Creating directory "bin\".
2019-03-29T15:51:47.5470138Z CoreCompile:
2019-03-29T15:51:47.5472670Z C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:TRACE /highentropyva+ /reference:D:\a\1\s\packages\Google.Protobuf.3.7.0\lib\net45\Google.Protobuf.dll /reference:D:\a\1\s\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\mscorlib.dll" /reference:D:\a\1\s\packages\MySql.Data.8.0.15\lib\net452\MySql.Data.dll /reference:D:\a\1\s\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.ComponentModel.DataAnnotations.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.ComponentModel.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Configuration.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Configuration.Install.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.Design.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Management.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll" /reference:D:\a\1\s\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.ServiceModel.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Transactions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Web.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Web.Extensions.dll" /reference:D:\a\1\s\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll /reference:D:\a\1\s\packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Xml.dll" /debug- /optimize+ /out:obj\Release\LoggingApi.dll /ruleset:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Static Analysis Tools\\Rule Sets\MinimumRecommendedRules.ruleset" /subsystemversion:6.00 /target:library /utf8output App_Start\WebApiConfig.cs App_Start\WebApiExceptionFilter.cs App_Start\WebApiNullCheckActionFilter.cs Authorization\WebApiAuthorization.cs Common.cs Constants.cs Controllers\BaseController.cs Controllers\MessageController.cs Dal.cs Global.asax.cs Controllers\EventsController.cs Models\LogEntryDto.cs Models\MessageDto.cs Properties\AssemblyInfo.cs "C:\Users\VssAdministrator\AppData\Local\Temp\.NETFramework,Version=v4.7.2.AssemblyAttributes.cs"
2019-03-29T15:51:47.6084430Z Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn
2019-03-29T15:52:08.9411825Z _CopyFilesMarkedCopyLocal:
2019-03-29T15:52:08.9412789Z Copying file from "D:\a\1\s\packages\MySql.Data.8.0.15\lib\net452\MySql.Data.dll" to "bin\MySql.Data.dll".
2019-03-29T15:52:08.9413051Z Copying file from "D:\a\1\s\packages\Google.Protobuf.3.7.0\lib\net45\Google.Protobuf.dll" to "bin\Google.Protobuf.dll".
2019-03-29T15:52:08.9413271Z Copying file from "D:\a\1\s\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll" to "bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll".
2019-03-29T15:52:08.9415018Z Copying file from "D:\a\1\s\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll" to "bin\Newtonsoft.Json.dll".
2019-03-29T15:52:08.9442165Z Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll" to "bin\System.Net.Http.Formatting.dll".
2019-03-29T15:52:08.9442252Z Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll" to "bin\System.Web.Http.dll".
2019-03-29T15:52:08.9442305Z Copying file from "D:\a\1\s\packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll" to "bin\System.Web.Http.WebHost.dll".
2019-03-29T15:52:08.9460232Z Creating "D:\a\1\s\LoggingApi\obj\Release\LoggingApi.csproj.CopyComplete" because "AlwaysCreate" was specified.
2019-03-29T15:52:08.9479340Z CopyFilesToOutputDirectory:
2019-03-29T15:52:08.9479432Z Copying file from "obj\Release\LoggingApi.dll" to "bin\LoggingApi.dll".
2019-03-29T15:52:08.9484851Z LoggingApi -> D:\a\1\s\LoggingApi\bin\LoggingApi.dll
2019-03-29T15:52:09.1237828Z CopyRoslynCompilerFilesToOutputDirectory:
[这里是罗斯林的东西]
2019-03-29T15:52:09.1587962Z Done Building Project "D:\a\1\s\LoggingApi\LoggingApi.csproj" (default targets).
答案 0 :(得分:0)
ASP.NET管道不发布内容
由于项目类型是网站,并且您不想使用发布配置文件,因此可以尝试以下方法:
在VS中创建发布配置文件后,将创建以下内容:
1)App_Data / PublishProfiles下的发布配置文件(.pubxml文件)
2)网站根目录中的 website.publishproj
website.publishproj
的目的是促进命令行发布。然后,您可以尝试使用 msbuild构建任务,如下所示进行发布:
msbuild.exe "WebSite1\website.publishproj" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"
这对于第一个命令也应该起作用:
msbuild.exe "WebSite1\website.publishproj" /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\" /p:DeployDefaultTarget=WebPublish /p:DeleteExistingFiles=true
希望这会有所帮助。