ClickOnce - 无法发布,因为项目构建失败

发布于 2024-12-11 06:13:05 字数 407 浏览 0 评论 0原文

当我尝试发布我的(WPF、C#)应用程序时,出现以下错误:
无法发布,因为项目构建失败。
找不到文件“obj\x86\Debug\MyAPP.exe”

无论从何处发布,我都会收到这些错误:发布向导、构建菜单或右键单击项目 - 发布。
首先它工作正常,但我做了以下操作:
我将计算机的日期更改为 10/10/2013,我正在尝试其他操作。
我忘记了这一点,然后单击“构建”。然后我在计算机上设置正确的日期。之后我收到这些错误。
另外,每次我单击“运行 Visual Studio 构建项目”时,项目中是否有更改。
我还注意到,当我设置 2013 年 10 月 10 日之后的日期时,它工作正常。
我猜测我正在我的项目中寻找一些设置,其中设置了构建日期。
我尝试过构建、重建、清理解决方案。

When I try to publish my (WPF, C#) application, I get these errors:
Cannot publish because a project failed to build.
Could not find file 'obj\x86\Debug\MyAPP.exe'

I get these errors no matter where from I publish: publish wizard, build menu or right click on project - publish.
First it was working ok, but I did the following:
I changed the date om my computer to 10/10/2013, I was trying something else.
I forgot this and I click build. Then I set the proper date on computer. After that I get these errors.
Also every time I click run Visual Studio builds project whether there are changes in project.
I also noticed that when I set the date after 10/10/2013 it works ok.
I am guessing that I am looking for some settings in my project where this date of build is set.
I tried build, rebuild, clean solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

﹏半生如梦愿梦如真 2024-12-18 06:13:05

这是 Visual Studio 的问题,当您安装了加载项时可能会出现此问题。不要使用“发布”选项卡中的“发布”按钮,而是使用 Visual Studio 顶部菜单中的“生成/发布”。

如果您使用“发布”按钮,它会在进行构建(或类似操作)之前运行加载项。如果您从菜单中使用“生成”,它将直接进入 msbuild 并忽略您已安装的任何加载项。

如果您安装了 DevExpress 但仍然遇到问题,请查看这篇文章:
http://www.devexpress.com/Support/Center/p/Q260132.aspx

This is a problem with Visual Studio that can occur when you have add-ins installed. Instead of using the Publish button in the Publish tab, use Build/Publish from the menu on the top of Visual Studio.

If you use the Publish button, it runs through the add-ins before doing the build (or something like that). If you use Build from the menu instead, it goes straight to msbuild and ignores any add-ins you have installed.

If you have DevExpress installed and are still having problems, check out this article:
http://www.devexpress.com/Support/Center/p/Q260132.aspx

那请放手 2024-12-18 06:13:05

日期恢复正常后,关闭 VS 并尝试删除 *.sln 文件旁边的 *.suo 文件,然后重新打开解决方案

With the date back to normal, close VS and try deleting your *.suo files next to the *.sln files and then reopen the solution

野の 2024-12-18 06:13:05

我不确定您的开发机器是如何以这种方式出现问题的,但我们小组中的几个开发人员也开始发生这种情况。

经过研究后发现,Visual Studio(在我们的例子中为 2010)使用的内置构建/发布脚本在执行操作的顺序上存在缺陷。最重要的是,它会在 OBJ 目录上运行清理操作,删除目标 EXE 文件,然后发布步骤才能获取它。

解决方案
这有点像黑客的解决方法,但它解决了我的问题。

修复方法是在发布步骤之前将文件从 /bin/ 文件夹复制回 /obj/ 文件夹。不幸的是,我不知道如何通过 IDE 指定 BeforePublish 事件,因此您必须在文本编辑器中编辑 .vbproj 文件。

在最后的 标记之前添加以下部分。

<Target Name="BeforePublish">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(IntermediateOutputPath)" />
</Target> 

I'm not sure exactly how your development machine can get fouled up this way, but this started happening for several developers in our group too.

After researching it, it appears that the built in build/publish script that Visual Studio (2010 in our case) uses has a flaw in the order that it does things. Most importantly it runs a cleanup on the OBJ directory deleting the target EXE file before the publish step can grab it.

The solution
This is somewhat of a hacky workaround, but it solved the problem for me.

The fix is to copy the file back to the /obj/ folder from the /bin/ folder right before the publish step. Unfortunately there is no way that I know to specify a BeforePublish event through the IDE, so you will have to edit the .vbproj file in a text editor.

Add the following section just before the final </project> tag.

<Target Name="BeforePublish">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(IntermediateOutputPath)" />
</Target> 
心在旅行 2024-12-18 06:13:05

我解决了我的问题。问题是某些文件的“修改”时间。我使用程序Timestamp来修复它。

正如我在问题中所说,问题是我构建了解决方案,并且日期是在未来。因此,每次我按 F5 时,Visual Studio 都会再次构建整个解决方案,并且 Publish ClickOnce 无法正常工作。

I solved my problem. The problem was the "Modified" time of some files. I used the program Timestamp to fix it.

As I said in my question, the problem was that I build the solution and the date was in the future. Because of that, every time I pressed F5 Visual Studio was building the whole solution again and Publish ClickOnce wasn't working.

可爱咩 2024-12-18 06:13:05

如果没有其他方法,请尝试以下操作:

  1. 将日期设置为正确的日期。
  2. 关闭 VS 后,删除解决方案的所有 bin 和 obj 文件夹。
  3. 创建一个新的空解决方案。
  4. 将您现有的项目添加到解决方案中。
  5. 添加回所需的参考文献。
  6. 重建以确保您没有错过任何内容。
  7. 发布。

如果您愿意,如果您不想制定新的解决方案,也可以先尝试步骤 1、2、6、7。

If nothing else works, try this :

  1. Set your date to the proper date.
  2. With VS closed, delete all the bin and obj folders of your solution.
  3. Create a new empty solution.
  4. Add your existing projects to the solution.
  5. Add back the needed references.
  6. Rebuild to make sure you didn't miss anything.
  7. Publish.

If you want, you can also just try step 1, 2, 6, 7 before, if you don't feel like making a new solution.

我ぃ本無心為│何有愛 2024-12-18 06:13:05

只需创建一个新的 ClickOnce 清单证书,它就会再次工作。

Just create a new ClickOnce manifest certificate, and it will work again.

小红帽 2024-12-18 06:13:05

我有时会遇到 ASP.NET 项目发布问题,因为发布向导无法删除它尝试将文件发布到的目录中的文件。

尝试在发布之前手动清除这些文件。还要检查输出窗口;有时它会给您一些关于发布失败原因的提示。

I have sometimes had problems with an ASP.NET project publishing, because the publish wizard couldn't delete files in the directory it was trying to publish the files to.

Try clearing out those file manually before publishing. Also check the output window; it will sometimes give you some hints as to why the publish failed.

╰沐子 2024-12-18 06:13:05

我今天刚遇到这个问题。就我的具体情况而言,这是由 Microsoft Windows UpdateMicrosoft 安全通报 2661254(关于最小证书密钥长度)。

我卸载了该更新并发布开始像往常一样工作。这只是一个临时解决方法,意味着您应该重新生成密钥/证书。

I just ran into the problem today. In my particular case, it was caused by Microsoft Windows Update, Microsoft Security Advisory 2661254 (concerning minimum certificate key length).

I uninstalled that update and publish began working as it always had. This is only a temporary work around and means you should probably regenerate your keys/certificates.

鹿港小镇 2024-12-18 06:13:05

当我交换 git 分支时,我遇到了这个错误。重建全部为我解决了这个问题。

I've had this error when I'd been swapping git branches. A Rebuild All fixed this for me.

み零 2024-12-18 06:13:05

就我而言,当我在 .csproj 文件中添加以下部分时出现问题:

<Target Name="AfterBuild">
</Target>

In my case, the problem arise when I added the following section in .csproj File:

<Target Name="AfterBuild">
</Target>
ヤ经典坏疍 2024-12-18 06:13:05

关闭和打开 Visual Studio 对我有用。

Closing and Opening Visual Studio worked for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文