【发布时间】:2017-11-09 00:04:34
【问题描述】:
我正在开发一个 ASP.NET 核心应用程序。
我在线使用 VSTS 进行源代码控制。我还有一台专用机器来构建应用程序。
为了自动化这个过程,我现在尝试从 VSTS 在线定义一个构建脚本。
默认的 VSTS 模板定义了许多任务。我出于自己的目的删除了所有不需要的任务,只剩下三个任务——“使用 NuGet”、“NuGet 还原”和“构建解决方案”。
“构建解决方案”任务的默认 msbuild 参数是:
/p:DeployOnBuild=true /p:WebPublishMethod=Package
/p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true
/p:DesktopBuildPackageLocation=
"$(build.artifactstagingdirectory)\WebApp.zip"
/p:DeployIisAppPath="Default Web Site"
虽然运行此脚本没有错误,但我需要对其进行更改,使输出进入文件夹并且不打包。
这是与我的问题相关的目录结构的一部分:
C:\Dev\RCWebsite\RCWebsite.sln
C:\Dev\RCWebsite\RCWeb\RCWeb.csproj
C:\Dev\RCWebsite\RCWeb\Properties\PublishProfiles\FolderProfile.pubxml
这是发布配置文件的内容:
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>d7d9f3b7-fd0e-49c1-b6d2-3af5dddb6699</ProjectGuid>
<publishUrl>C:\StagingSites\rcweb</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
</PropertyGroup>
从控制台窗口,我可以运行以下命令:
msbuild .\RCWeb\RCWeb.csproj /p:DeployOnBuild=true
/p:PublishProfile=RCWeb\Properties\PublishProfiles\FolderProfile.pubxml
这按预期工作。最终输出在C:\StagingSites\rcweb\目录下生成。
由于此命令有效,我将 VSTS“构建解决方案”任务中的 msbuild 参数替换为:
/p:DeployOnBuild=true
/p:PublishProfile=rcWeb\Properties\PublishProfiles\FolderProfile.pubxml
请注意,我没有指定 .\RCWeb\RCWeb.csproj 作为参数。猜猜构建机制会自动处理这个问题。
当我运行此构建并查看日志文件时,我发现解决方案构建良好。但是,它永远不会复制到C:\StagingSites\rcweb\ 目录。
谁能告诉我我错过了什么?在“构建解决方案”任务之后我是否需要另一个“部署”任务?问候。
【问题讨论】:
-
您是否尝试指定发布配置文件的完整路径?
$(Build.SourcesDirectory)会给你根文件夹。 -
感谢您的帮助。我会试试的。我假设如果找不到发布配置文件,我会在日志文件中看到错误。
-
不幸的是没有用:-(
-
msbuild 参数
/p:DeployOnBuild=true /p:PublishProfile=rcWeb\Properties\PublishProfiles\FolderProfile.pubxm可以将发布文件复制到C:\StagingSites\rcweb目录。所以请检查构建代理是在本地机器上设置的私有代理。此外,您能在此处提供完整的构建日志吗?
标签: azure-devops azure-pipelines