【问题标题】:ASP.NET Pipeline Not Publishing ContentASP.NET 管道不发布内容
【发布时间】:2019-04-01 14:17:33
【问题描述】:

我正在尝试在 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).

【问题讨论】:

  • MSBuild 输出是什么样的?
  • @DanielMann 不允许我将完整的 msbuild 日志输出放入其中。您要查找的任何特定部分?
  • 打包二进制文件的部分。另外,请注意/p:SkipInvalidConfigurations=true。您确定平台/配置有效吗?
  • @DanielMann 我在本地构建中使用了相同的参数来测试它。本地没有问题。更新主帖;将省略 roslyn 部分。
  • @DanielMann 进行了另一项测试,删除了 /p:SkipInvalidConfigurations=true;仍然没有文件被发布。

标签: msbuild azure-devops azure-pipelines


【解决方案1】:

ASP.NET 管道不发布内容

由于项目类型是网站,你不想使用发布配置文件,你可以尝试以下方法:

在 VS 中创建发布配置文件后,将创建以下内容:

1) App_Data/PublishProfiles 下的发布配置文件(.pubxml 文件)

2) 网站根目录中的 website.publishproj

website.publishproj 的目的是方便命令行发布。然后你可以尝试使用 msbuild build task 来发布它:

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

希望这会有所帮助。

【讨论】:

  • 我会尝试使用发布配置文件,但我正在寻找一种不需要它的方法。希望这不适用于单个文件包,因为我需要它们。
  • Going Build > Publish Website 不会在根目录或 App_Data 下的任何内容中创建 website.puhlishproj。在 Properties > PublishProfiles 中只创建了一个 FolderProfile.pubxml。仍在寻找一种不使用配置文件的方法,就像我在 TFS2013 构建定义/解决方案中能够使用的那样。
猜你喜欢
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多