我在VS 2012中有一个Web应用程序项目,当我使用Web发布工具时,它成功地构建了,但没有将任何文件复制到发布目标(在这种情况下是文件系统)。

如果我看构建输出,我可以看到一切都被复制到obj\Release\Package\PackageTmp\正确,但然后我在构建输出中看到的是这样的:

4>完成建设项目“{project}.csproj”。 4>删除现有文件… 4>发布文件夹/… 4 > ========== 构建:3成功了,0失败,1最新的,0跳过 ========== ========== 发布:1成功,失败,0跳过 ==========

即使它说发布成功,但目标目录中没有用于发布的文件。

我在多个项目中看到过这种情况,有时似乎是解决方案/平台配置导致了这个问题,但我还不能确定造成这个问题的确切原因。

有人见过这种情况吗?或者有人知道如何让它正确工作吗?

更新:

我可能找到了一个变通办法。这又发生了,我把发布设置弄乱了。一旦我改变了设置选项卡上选择的配置到另一个配置,然后回到我想要使用的所有文件再次开始发布。希望这在未来的其他项目中也适用。

更新2:

我在Microsoft Connect上发布了一个bug,并从VS Web developer团队的开发人员那里得到了回复。他说他们已经在内部版本中修复了这个问题,并将很快发布发布工具的更新来修复这个问题。

更新3:

最近Visual Studio 2012 Update 2修复了这个问题


当前回答

更进一步说。在创建发布配置文件时,将创建两个文件。

NewProfile.pubxml NewProfile.pubxml.user

当您从源代码控制打开一个在PublishProfile文件夹中包含这些文件的项目时,它只有.pubxml文件,而没有. publicxml文件。用户文件,因此它创建了。publicxml。用户文件在运行时打开项目。 当它创建新的. publicxml . xml时。用户在飞行的XML看起来像:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

当你创建一个新的配置文件时,它创建的xml看起来像:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <TimeStampOfAssociatedLegacyPublishXmlFile />
    <EncryptedPassword />
  </PropertyGroup>
</Project>

如果取<PropertyGroup>节点并将其放在.pubxml. xml文件中。用户文件你的PublishProfiles将重新开始工作。

其他回答

我有同样的错误,我改变了设置从发布调试和问题解决。

我的问题是在错误的配置我的项目。csproj文件。“_address-step1-stored。Cshtml的文件在发布时没有复制。“None”改为“Content”,现在没问题了。

最近在VS 2013的一个MVC项目中,我导入了Umbraco CMS,遇到了同样的问题。我不能出版。上面的答案很有帮助,尽管我需要一段时间来弄清楚我在vs中应该做什么。这需要一些研究,比如在MS博客上找到答案。我试着简单地说:

Choose in the VS toolbar a certain configuration e.g. Release and Any CPU. Run the project. Afterwards right-click in the Solution Explorer on the solution in question, choose Publish. Create a new publishing profile or use a given one, but always make sure that in the settings the same configuration (e.g. Release and Any CPU) is chosen, as before you run the project the last time. Additionally in my case it was necessary to delete the OBJ folder because here the settings from my last unsuccessful tries to publish got stuck, though I restarted VS and deleting all publishing profiles.

以上的方法对我来说都没用。

但我注意到我们的五个ASP。NET MVC项目在我们的主要解决方案中,其中四个将部署包放在正确的位置,而一个将它留在obj\Debug下。

我比较了这些项目,发现了不一致之处。解决办法是改变这一点:

<Import
    Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

:

<Import
  Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets"
  Condition="'$(VSToolsPath)' != ''" />
<Import
  Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets"
  Condition="false" />

在我做了这个更改之后,所有五个项目都将它们的部署包放在了正确的位置。

(很抱歉排了这么长的队,但我找不到更好的方式来浓缩它们。)

更进一步说。在创建发布配置文件时,将创建两个文件。

NewProfile.pubxml NewProfile.pubxml.user

当您从源代码控制打开一个在PublishProfile文件夹中包含这些文件的项目时,它只有.pubxml文件,而没有. publicxml文件。用户文件,因此它创建了。publicxml。用户文件在运行时打开项目。 当它创建新的. publicxml . xml时。用户在飞行的XML看起来像:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

当你创建一个新的配置文件时,它创建的xml看起来像:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <TimeStampOfAssociatedLegacyPublishXmlFile />
    <EncryptedPassword />
  </PropertyGroup>
</Project>

如果取<PropertyGroup>节点并将其放在.pubxml. xml文件中。用户文件你的PublishProfiles将重新开始工作。