【问题标题】:Why won't my msbuild deploy work after I check "Precompile during publishing" on the publish properties?在发布属性上检查“发布期间预编译”后,为什么我的 msbuild 部署无法工作?
【发布时间】:2015-02-23 01:01:15
【问题描述】:

我检查了下面的中间选项“发布期间预编译”。

这将 FDeploy.pubxml 文件更改了几行。美好的。我将这个单一的更改提交到我的构建服务器。

这里是 pubxml:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>C:\Temp</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>False</EnableUpdateable>
    <DebugSymbols>False</DebugSymbols>
    <WDPMergeOption>DonotMerge</WDPMergeOption>
  </PropertyGroup>
</Project>

已通过启用 mvcbuildviews 的远程构建。远程部署失败,出现如下错误:

Error   82  The name 'ViewBag' does not exist in the current context
Error   5   The name 'model' does not exist in the current context  

等等。这样的错误有100多个。请记住,启用常规 msbuildviews 的 msbuild 步骤使用相同的代码可以正常工作。

我以这种方式在 web 项目 csproj 上使用 msbuild:

/p:DeployOnBuild=true /p:PublishProfile=FDeploy /p:VisualStudioVersion=12.0 /p:Configuration=Release

有什么线索吗?哦,是的,选中该框也会在我的开发机器上引起同样的错误,我不得不完全删除 bin、obj 和 appdata 文件夹以中和它。但是,在构建服务器上进行新的检查并没有帮助。

另请注意,当我返回旧部署配置文件时,需要重新签出以修复部署。

【问题讨论】:

  • 同样的问题,有进展吗?
  • 很遗憾没有,但我迟早要解决这个问题,我会及时通知您
  • @Mark Lopez - 找到了一个解决方案,但也许不是你想要的,马克。
  • 这也是我的解决方案。我认为这是我们构建目标之一的问题,尽管使用调试符号运行实际上最终对生产有帮助,因此我们选择保留它。
  • 令人讨厌的是,当我部署它时,它会对 bin、obj 或 appdata 执行某些操作,从而破坏未来从同一个结帐中构建的“调试”。 Mvcbuildviews 完全失败并给出各种疯狂的错误。

标签: asp.net-mvc razor msbuild publish


【解决方案1】:

我不得不作弊来解决这个问题:我将 MvcBuildViews 的使用限制为项目的“调试”版本:

在csproj文件中:

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>

我在部署时使用 mvcbuildviews 遇到了其他莫名其妙的错误。似乎最好完全避免使用它。无论如何,构建仍然保持干净,因为我也编译和测试了调试版本。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-25
    • 2014-03-27
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多