简体   繁体   English

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

[英]ClickOnce - Cannot publish because a project failed to build

When I try to publish my (WPF, C#) application, I get these errors: 当我尝试发布我的(WPF,C#)应用程序时,我收到以下错误:
Cannot publish because a project failed to build. 无法发布,因为项目无法构建。
Could not find file 'obj\\x86\\Debug\\MyAPP.exe' 找不到文件'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. 我将计算机的日期更改为10/10/2013,我正在尝试别的东西。
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. 每次我单击运行Visual Studio构建项目是否有项目更改。
I also noticed that when I set the date after 10/10/2013 it works ok. 我也注意到,当我在2013年10月10日之后设置日期时,它工作正常。
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. 我尝试了构建,重建,清洁解决方案。

This is a problem with Visual Studio that can occur when you have add-ins installed. 这是安装了加载项时可能出现的Visual Studio问题。 Instead of using the Publish button in the Publish tab, use Build/Publish from the menu on the top of Visual Studio. 不使用“发布”选项卡中的“发布”按钮,而是使用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. 如果您使用菜单中的Build,它会直接进入msbuild并忽略您安装的任何加载项。

If you have DevExpress installed and are still having problems, check out this article: http://www.devexpress.com/Support/Center/p/Q260132.aspx 如果您安装了DevExpress但仍有问题,请查看以下文章: http//www.devexpress.com/Support/Center/p/Q260132.aspx

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

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. 在研究它之后,看起来Visual Studio(在我们的例子中是2010)使用的内置构建/发布脚本在它执行操作的顺序中存在缺陷。 Most importantly it runs a cleanup on the OBJ directory deleting the target EXE file before the publish step can grab it. 最重要的是,它会在OBJ目录上运行清理,删除目标EXE文件,然后发布步骤才能获取它。

The solution 解决方案
This is somewhat of a hacky workaround, but it solved the problem for me. 这有点像一个hacky解决方法,但它解决了我的问题。

The fix is to copy the file back to the /obj/ folder from the /bin/ folder right before the publish step. 解决方法是在发布步骤之前将文件从/bin/文件夹复制回/obj/文件夹。 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. 遗憾的是,我无法通过IDE指定BeforePublish事件,因此您必须在文本编辑器中编辑.vbproj文件。

Add the following section just before the final </project> tag. 在最终的</project>标记之前添加以下部分。

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

I solved my problem. 我解决了我的问题。 The problem was the "Modified" time of some files. 问题是某些文件的“修改”时间。 I used the program Timestamp to fix it. 我使用程序Timestamp来修复它。

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. 因此,每次我按下F5 Visual Studio都会再次构建整个解决方案而Publish ClickOnce无法正常工作。

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

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. 关闭VS后,删除解决方案的所有bin和obj文件夹。
  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. 如果您愿意,您也可以尝试之前的步骤1,2,6,7,如果您不想制作新的解决方案。

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). 在我的特定情况下,它是由Microsoft Windows UpdateMicrosoft安全通报2661254 (关于最小证书密钥长度)引起的。

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. 这只是一个临时工作,意味着你应该重新生成你的密钥/证书。

I've had this error when I'd been swapping git branches. 当我交换git分支时,我遇到了这个错误。 A Rebuild All fixed this for me. A Rebuild All为我解决了这个问题。

In my case, the problem arise when I added the following section in .csproj File: 在我的情况下,当我在.csproj文件中添加以下部分时出现问题:

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

关闭和打开Visual Studio为我工作。

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. 我有时遇到ASP.NET项目发布问题,因为发布向导无法删除尝试将文件发布到的目录中的文件。

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. 它有时会给你一些提示,说明发布失败的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM