构建成功,但发布失败

问题描述 投票:37回答:19

直到两天前,我能够通过右键单击我的项目并单击上下文菜单上的“发布”按钮来使用Visual Studio 2010的“发布Web”选项。现在当我尝试做同样的事情时,我得到以下输出:

------ Build started: Project: ELMS, Configuration: Debug Any CPU ------
Build started 8/1/2011 3:08:03 PM.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are
up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectoryAlways:
Copying file from "C:\SVN\TrakNet\trunk\MTS\lib\Newtonsoft.Json.Net35.dll" to 
  "bin\lib\Newtonsoft.Json.Net35.dll".
CopyFilesToOutputDirectory:
  LMS -> C:\SVN\TrakNet\trunk\MTS\bin\LMS.dll

Build succeeded.

Time Elapsed 00:00:00.04
------ Publish started: Project: LMS, Configuration: Debug Any CPU ------
Object reference not set to an instance of an object.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

这是在尝试发布到localhost时(用于调试目的)

以下是我正在使用的发布配置文件的设置:

Publish Method: Web Deploy
Service URL: localhost
Site/application: default web site/ELMS
[x] Mark as IIS application on destination
[x] Leave extra files on destination (do not delete)

我已经尝试过了:

- Cleaning/rebuilding the project
- Deleting the bin folder of the project
- Running reg_iis.exe -i
- Reinstalling VS2010

但我没有改变任何东西修复了错误。

任何洞察可能导致问题的原因将非常感谢:)

编辑:

我上次重启时问题实际上已经解决了。自问题首次出现以来,我必须重新启动6-7次,但这次没有对象参考消息。这是现在构建/发布的日志:

------ Build started: Project: LMS, Configuration: Debug Any CPU ------
Build started 8/3/2011 9:10:12 AM.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
_CopyOutOfDateSourceItemsToOutputDirectoryAlways:
  Copying file from "C:\SVN\TrakNet\trunk\MTS\lib\Newtonsoft.Json.Net35.dll" to "bin\lib\Newtonsoft.Json.Net35.dll".
CopyFilesToOutputDirectory:
  LMS -> C:\SVN\TrakNet\trunk\MTS\bin\LMS.dll

Build succeeded.

Time Elapsed 00:00:00.04
------ Publish started: Project: LMS, Configuration: Debug Any CPU ------
Gather all files from Project items @(IntermediateAssembly). Adding:
bin\LMS.dll to bin\LMS.dll
bin\LMS.pdb to bin\LMS.pdb
Gather all files from Project items @(Content). Adding:
Global.asax;lib\Newtonsoft.Json.Net35.dll;MtsSchemas\MtsSchema.xml;Web.config
Gather all files from Project output (IntermediateSatelliteAssembliesWithTargetPath).
Adding:
Gather all files from Project items
@(ReferenceCopyLocalPaths,ReferenceComWrappersToCopyLocal,ResolvedIsolatedComModules,_DeploymentLooseManifestFile,NativeReferenceFile).
Gather all files from Project items @(AllExtraReferenceFiles). Adding:
Gather all files from Project items
@(_SourceItemsToCopyToOutputDirectoryAlways,_SourceItemsToCopyToOutputDirectory). Adding:
bin\lib\Newtonsoft.Json.Net35.dll
Gather all files from Project items @(_binDeployableAssemblies). Adding:
Publish Pipeline Collect Files Phase
Found The following for Config tranformation:
Web.config
Creating directory "C:\SVN\TrakNet\trunk\MTS\obj\Debug\TransformWebConfig\transformed\".
Publish Pipeline Transform Phase
Creating directory "C:\SVN\TrakNet\trunk\MTS\obj\Debug\CSAutoParameterize\transformed\".
Copying Web.config to obj\Debug\CSAutoParameterize\original\Web.config.
Transforming Source File: C:\SVN\TrakNet\trunk\MTS\Web.config
  Applying Transform File: <?xml version="1.0"?>
        <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
          <connectionStrings>
            <add
              connectionString="{% token='$(ReplacableToken_#(parameter)_#(tokennumber))' xpathlocator='name' parameter='$(name)-Web.config Connection String' description='$(name) Connection String used in web.config by the application to access the database.' defaultValue='$(connectionString)' tags='SqlConnectionString' %}"
              xdt:Transform="SetTokenizedAttributes(connectionString)" xdt:SupressWarnings="True" />
          </connectionStrings>
        </configuration>
      Output File: obj\Debug\CSAutoParameterize\transformed\Web.config
    Transformation succeeded
Auto ConnectionString Transformed Web.config into obj\Debug\CSAutoParameterize\transformed\Web.config.
Creating directory "obj\Debug\Package\PackageTmp".
Copying all files to temporary location below for package/publish:
obj\Debug\Package\PackageTmp.
Copying bin\LMS.dll to obj\Debug\Package\PackageTmp\bin\LMS.dll.
Copying bin\LMS.pdb to obj\Debug\Package\PackageTmp\bin\LMS.pdb.
Copying Global.asax to obj\Debug\Package\PackageTmp\Global.asax.
Copying lib\Newtonsoft.Json.Net35.dll to obj\Debug\Package\PackageTmp\lib\Newtonsoft.Json.Net35.dll.
Copying MtsSchemas\MtsSchema.xml to obj\Debug\Package\PackageTmp\MtsSchemas\MtsSchema.xml.
Copying C:\SVN\TrakNet\trunk\MTS\lib\Newtonsoft.Json.Net35.dll to obj\Debug\Package\PackageTmp\bin\lib\Newtonsoft.Json.Net35.dll.
Copying obj\Debug\CSAutoParameterize\transformed\Web.config to obj\Debug\Package\PackageTmp\Web.config.
Publish Pipeline Deploy phase Pre-Deploy CopyAllFilesToOneFolder Stage
Generate source manifest file for Web Deploy package/publish ...
Creating directory "obj\Debug\Database".
Starting Web deployment task from source:manifest(C:\SVN\TrakNet\trunk\MTS\obj\Debug\Package\LMS.SourceManifest.xml) to Destination:auto().
Updating filePath (default web site/LMS\bin\ELMS.dll).
Updating filePath (default web site/LMS\bin\ELMS.pdb).
Updating filePath (default web site/LMS\bin\lib\Newtonsoft.Json.Net35.dll).
Updating filePath (default web site/LMS\lib\Newtonsoft.Json.Net35.dll).
Updating filePath (default web site/LMS\Web.config).
Updating setAcl (default web site/LMS).
Updating setAcl (default web site/LMS).
Successfully executed Web deployment task.
Publish is successfully deployed.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

就像我说的:不知道改变了什么。我一直在手动将DLL移动到网站的虚拟目录中,然后只是为了我今天早上尝试发布的踢,一切都很顺利。

asp.net visual-studio-2010 iis-7.5 publish msbuild-wpp
19个回答
37
投票

根据我的经验,这可能发生在源控件的不同分支中添加/删除文件时,不完美的合并会导致项目文件结构和实际文件结构发生分歧。

这可能是以下几种选择之一:

  • 文件已删除但项目仍引用它。将无法编译,将无法发布。
  • 添加了一个文件,但项目未引用该文件。可以编译,取决于类/方法是否在项目/解决方案的其他地方引用。如果编译,将发布。
  • 添加了一个文件,但项目合并导致它在项目列表中出现多次。将编译,将无法发布。

解决方案是查看源控件日志并尝试识别针对上述问题的项目文件的错误合并,然后相应地修复项目文件。


0
投票

当我手动将文件夹复制到项目中时(我的情况下是ckeditor),我遇到了类似的问题。它建好并在本地运行没有问题。但是,在发布文件夹时被忽略。事实证明,我必须创建第一个空文件夹,然后复制文件夹内容。 Visual Studio需要知道它出现的项目是否已创建,因为之后它在发布时被识别。


0
投票

此问题可能是因为将项目从一个解决方案移动到另一个解决方案或转移到另一个源控件。

解决此问题的简单方法:

  1. 获取当前项目备份并从解决方案中删除当前项目。
  2. 将新项目添加到您的解决方案中,并从备份中包含您的文件并重建您的项目并完成。

0
投票

它的原因是从不同的环境转移你的项目。要解决此问题,请通过右键单击“obj”文件夹,从项目目录以及解决方案资源管理器中删除“obj”文件夹。

之后构建您的项目并发布它。它会正常工作。


0
投票

我通过从我的项目中删除文件“packages.config”解决了这个问题,该文件被标记为缺失。之后,Publish工作得很好。


0
投票

我不得不手动复制并粘贴VS要求进入BIN文件夹的丢失文件。 .pbd,.xml有时他们不会复制。


0
投票

只需重命名Nugets的Packages文件夹即可。 Visual Studio将自动获得所需的包,构建将获得成功,Publish也可以工作。


0
投票

如果这有助于任何人,对于我在VS 2015中的MVC项目,就是这个文件:File System.pubxml.user在发布配置文件目录中,包括它导致编译错误但删除它使它能够发布!


0
投票

我不得不删除发布配置文件,提交,然后从头开始重新创建发布配置文件。


0
投票

我删除了visual studio中所有现有的发布配置文件 - >解决方案资源管理器 - >我的项目节点 - >属性 - >发布配置文件右键单击解决方案资源管理器中的项目 - >发布 - >配置文件选项卡 - >管理配置文件 - >删除所有配置文件现在从Azure下载相关配置文件,或者从您的目录中选择,如果它已保存在您的计算机上并选择它。然后清理并重建项目。确保您选择的项目是在发布模式下构建的,并且您还选择了“发布”发布 - >设置 - >立即配置发布,它对我有用。


0
投票

我也在发布我的网站时遇到了这个问题,在我的情况下引用了参考文献但是在bin文件夹中它不存在所以请再次安装哪个引用缺少输出。我希望它有帮助


17
投票

我也面临同样的问题,我刚从visual studio项目解决方案中删除了黄色标记文件,它对我来说很好。


10
投票

从项目中排除bin(和/或)obj文件夹并发布。这对我有用


4
投票

我最近有这个问题发布到Azure。我最终删除了bin文件夹中的所有文件(删除了bin文件夹下的visual studio解决方案资源管理器中的所有文件,但是将bin文件夹本身留空),并重建项目。这似乎使视觉工作室开心,天蓝色的出版工作。希望这可以帮助


3
投票

这对我有用:手动删除obj文件夹,重建,然后发布。不知何故obj文件夹中的某些权限被卡住了,删除/重新创建文件夹清除了错误。


3
投票

我删除了bin&obj文件夹以及inetpub / wwwroot / myapp的内容和问题解决


2
投票

nothings为我工作。删除obj和bin文件清理更改webservice名称 - 缩短webservice名称。

但是,根本,

+从visual studio扩展Reference.svcmap。

+更新参考。

+并删除黄色警告数据源。

适合我


1
投票

在记事本中打开projectname.csproj文件并删除obj \ debug \ project name.csprojResolveAsseblyReference.cache line


1
投票

我最近遇到了同样的问题。我实际上通过搜索丢失的文件来追踪它。

错误的原因:在visual studio中我已经包含了文件,后来又从文件系统中删除了它(但不是来自visual studio)。 VS仍然有对该文件的引用。所以一旦我删除了VS的引用,我就能成功发布!

© www.soinside.com 2019 - 2024. All rights reserved.