C# 未为此项目设置 OutputPath 属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9086795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The OutputPath property is not set for this project
提问by Amzath
When I try to compile my project from x86 debug mode in Visual Studio 2008. I am getting this error. When I looked at the property group of the project that complained, I see output path is set.
当我尝试在 Visual Studio 2008 中从 x86 调试模式编译我的项目时。我收到此错误。当我查看抱怨的项目的属性组时,我看到设置了输出路径。
Here is the property group section for that .csproj file
这是该 .csproj 文件的属性组部分
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseAddress>285212672</BaseAddress>
<FileAlignment>4096</FileAlignment>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
Can any one shed the light on this?
任何人都可以阐明这一点吗?
NOTE: When I compiled this Debug and Any CPU it worked.
注意:当我编译这个 Debug 和 Any CPU 时,它可以工作。
UPDATED:Error 1 The OutputPath property is not set for this project. Please check to make sure that you have specified a valid Configuration/Platform combination. Configuration='Debug' Platform='x86'
更新:错误 1 未为此项目设置 OutputPath 属性。请检查以确保您指定了有效的配置/平台组合。配置='调试' 平台='x86'
采纳答案by Amzath
The error shown in visual studio for the project (Let's say A) does not have issues. When I looked at the output window for the build line by line for each project, I saw that it was complaining about another project (B) that had been referred as assembly in project A. Project B added into the solution. But it had not been referred in the project A as project reference instead as assembly reference from different location. That location contains the assembly which compiled for Platform AnyCpu. Then I removed the assembly reference from the project A and added project B as a reference. It started compiling. Not sure though how this fix worked.
Visual Studio 中显示的项目错误(假设为 A)没有问题。当我逐行查看每个项目的构建输出窗口时,我看到它在抱怨另一个项目 (B),它在项目 A 中被称为程序集。项目 B 添加到解决方案中。但是它在项目 A 中没有被称为项目引用,而是作为来自不同位置的程序集引用。该位置包含为 Platform AnyCpu 编译的程序集。然后我从项目 A 中删除了程序集引用,并添加了项目 B 作为引用。它开始编译。不确定这个修复程序是如何工作的。
回答by dblood
You can see this error in VS 2008 if you have a project in your solution that references an assembly that cannot be found. This could happen if the assembly comes from another project that is not part of your solution but should be. In this case simply adding the correct project to the solution will solve it.
如果您的解决方案中有一个引用无法找到的程序集的项目,则您可以在 VS 2008 中看到此错误。如果程序集来自不属于您的解决方案但应该属于的另一个项目,则可能会发生这种情况。在这种情况下,只需将正确的项目添加到解决方案中即可解决。
Check the References section of each project in your solution. If any of them has a reference with an red x next to it, then it you have found your problem. That assembly reference cannot be found by the solution.
检查解决方案中每个项目的参考部分。如果它们中的任何一个旁边有一个红色 x 的参考,那么你就发现了你的问题。解决方案无法找到该程序集引用。
The error message is a bit confusing but I've seen this many times.
错误消息有点令人困惑,但我已经看到过很多次了。
回答by Keith Hoffman
Another crazy possibility: If you follow a simple source control arrangement of putting Branch\Main, Main, and Release next to each other and you somehow end up adding an existing project from Main instead of Branch\Main (assuming your working solution is Branch\Main), you may see this error.
另一个疯狂的可能性:如果您遵循将 Branch\Main、Main 和 Release 放在一起的简单源代码控制安排,并且以某种方式最终从 Main 而不是 Branch\Main 添加现有项目(假设您的工作解决方案是 Branch\ Main),您可能会看到此错误。
The solution is simple: reference the right project!
解决方案很简单:引用正确的项目!
回答by B-K
I encountered the same error but the problem turned out to be because I had created a new configuration in my solution that didn't exist in referenced assemblies from another solution.
我遇到了同样的错误,但结果证明问题是因为我在我的解决方案中创建了一个新配置,而该配置在另一个解决方案的引用程序集中不存在。
This can be resolved by opening the related solution and adding the new configuration to it as well.
这可以通过打开相关解决方案并向其添加新配置来解决。
This post gave me the idea to check the referenced assemblies after I'd already confirmed that all projects within my solution had the correct configuration:
在我已经确认我的解决方案中的所有项目都具有正确的配置之后,这篇文章给了我检查引用的程序集的想法:
http://gabrielmagana.com/2010/04/solution-to-the-outputpath-property-is-not-set-for-this-project/
http://gabrielmagana.com/2010/04/solution-to-the-outputpath-property-is-not-set-for-this-project/
回答by StuTheDog
I encountered this problem when adding a project to a solution then referencing it from yet another project in the same solution-- got the yellow warning icon over the reference, notice that path was empty.
我在将项目添加到解决方案然后从同一解决方案中的另一个项目引用它时遇到了这个问题 - 在引用上出现黄色警告图标,注意路径为空。
The solution was similar to what @Amzath suggested, my projects were being compiled with different Target Frameworks, eg. .NET 4.0 vs 4.5.
该解决方案与@Amzath 建议的类似,我的项目正在使用不同的目标框架进行编译,例如。.NET 4.0 与 4.5。
回答by Lukas Dvorak
I had the same error, so I looked on project settings and there in "Build" section is "Build output path" option. And value was empty. So I filled in "bin\" value a error disappeared. It solved my problem.
我有同样的错误,所以我查看了项目设置,“构建”部分中有“构建输出路径”选项。价值是空的。于是我填入“bin\”值一个错误就消失了。它解决了我的问题。
回答by Jesus Manuel
In my case the built address of my app was set to another computer that was turned off so i turned it on and restart VS and problem solved.
在我的情况下,我的应用程序的构建地址设置为另一台已关闭的计算机,因此我将其打开并重新启动 VS 并解决了问题。
回答by george
If you are using WiX look at this (there is a bug) http://www.cnblogs.com/xixifusigao/archive/2012/03/20/2407651.html
如果你使用 WiX 看这个(有一个 bug) http://www.cnblogs.com/xixifusigao/archive/2012/03/20/2407651.html
Sometimes new build configurations get added to the .wixprojfile further down the file, that is, separated from their sibling config definitions by other unrelated XML elements.
有时,新的构建配置会被添加到.wixproj文件更下方的文件中,也就是说,通过其他不相关的 XML 元素将其与其同级配置定义分开。
Simply edit the .wixprojfile so that all the <PropertyGroup>sections that define your build configs are adjacent to one another. (To edit the .wixprojin VS2013 right click on project in Solution Explorer, Unload project, right-click again->Edit YourProject.wixproj. Reload after editing the file.)
只需编辑该.wixproj文件,以便<PropertyGroup>定义构建配置的所有部分彼此相邻。(要.wixproj在 VS2013 中右键单击解决方案资源管理器中的项目,卸载项目,再次右键单击->Edit YourProject.wixproj。编辑文件后重新加载。)
回答by David White
Another cause: you add a project reference from project A to project B in solution X. However, solution Y that already contains project A is now broken, until you also add project B to solution Y.
另一个原因:您将项目 A 的项目引用添加到解决方案 X 中的项目 B。但是,已经包含项目 A 的解决方案 Y 现在已损坏,直到您还将项目 B 添加到解决方案 Y。
回答by MihaiB
I had the same problem after I have added new configurations and deleted the "debug" and "release" configs. In my case I was using a cmd file to run the build and publish process, but the same error was thrown. The solution for me:In the csproj file the following:
添加新配置并删除“调试”和“发布”配置后,我遇到了同样的问题。在我的情况下,我使用 cmd 文件来运行构建和发布过程,但抛出了相同的错误。 我的解决方案:在 csproj 文件中如下:
<Configuration Condition=" '$(Configuration)' == '' ">Debug< /Configuration>
was setting the Configuration to "Debug" if I did not specify an explicit one. After changing the node value from "debug" to my custom configuration, it all worked smoothly. Hope this will also help whoever is reading this :)
如果我没有指定明确的配置,则将配置设置为“调试”。将节点值从“调试”更改为我的自定义配置后,一切顺利。希望这也能帮助阅读本文的人:)

