Visual Studio 和 Visual Studio 的区别MSBuild 处理 Web 应用程序项目的 OutputPath

发布于 2024-10-18 07:58:03 字数 1592 浏览 12 评论 0 原文

我正在使用 VS 2010 Web 应用程序项目。我想将 Web 应用程序的默认 OutputPath 属性更改为其他位置的目录。当我在解决方案中有其他项目时,这似乎并不完全有效:

首先:

  • 创建一个空白的 Web 应用程序项目,WebApplication1
  • bin 更改项目属性中的 OutputPathc:\binaries
  • 在解决方案资源管理器中右键单击该项目,然后构建。

一切都按预期工作,并且 WebApplication1.dll 被复制到 c:\binaries

然后:

  • 将类库添加到同一解决方案中,ClassLibrary1
  • 将类库添加为 Web 应用程序的项目引用。
  • 右键单击解决方案资源管理器中的 Web 应用程序项目,然后构建。

ClassLibrary1.dllWebApplication1.dll 都被复制到 c:\binaries但是现在有一个 <创建的strong>WebApplication1\Bin目录仅包含ClassLibarary1.dll

问题:

以前有人遇到过这种情况吗?我在网上找到的唯一参考是 这个,没有答案。欣赏任何禁止创建 Bin 文件夹的方法。

更多信息

  • 这只发生在从视觉工作室内部构建时。如果我使用 msbuild WebApplication1.csproj,则不会创建这个神秘的 Bin 目录。

  • 我仔细研究了 msbuild 日志,但无济于事。我找不到与该路径相关的任何属性。 Bin 的大写 B 也很奇怪,在 msbuild 中使用的所有路径通常都是 bin

  • 最后,我从 Web 应用程序的 proj 文件中删除了 WebApplication.targets 文件导入,但它没有产生任何影响。事实上,查看 msbuild 日志,似乎没有执行 WebApplication.targets 中的任何目标。

I am using VS 2010 web-application project. I want to change the default OutputPath property of the web-application to a directory elsewhere. This does not seem to be entirely working when I have an other project in the solution:

FIRST:

  • Create a blank web-application project, WebApplication1
  • Change the OutputPath in the project's properties from bin to c:\binaries
  • Right-click on the project in solution explorer, and build.

Everything works as expected, and WebApplication1.dll is copied to the c:\binaries.

THEN:

  • Add a class library to the same solution, ClassLibrary1
  • Add the class library as project reference to the web application.
  • Right-click on the web-application project in solution explorer, and build.

Both ClassLibrary1.dll and WebApplication1.dll are copied to c:\binaries, but now there is a WebApplication1\Bin directory created which contains only ClassLibarary1.dll

QUESTION:

Has anyone encountered this before? The only reference on the web I found was this, with no answer. Appreciate any way to disable creation of the Bin folder.

MORE INFO

  • This only happens when building from inside visual studio. If I use msbuild WebApplication1.csproj, this mysterious Bin directory is not created.

  • I dug through the msbuild logs, but to no avail. I could not find any property pertaining to that path. The capital B for Bin is also strange, all paths when used in msbuild are usually bin.

  • Last I removed the WebApplication.targets file Import from the web application's proj file but it did not make a difference. In fact, looking at the msbuild logs, there do not seem to be any targets from the WebApplication.targets getting executed.

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

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

发布评论

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

评论(1

一身软味 2024-10-25 07:58:03

您的 Web 应用程序的默认输出路径与 webapplication1 项目目录相同。 Bin 目录由您的站点内部使用来查找依赖程序集的位置(请参阅 探测)。默认情况下,Microsoft.Web.Publishing.targets 使用它在本地复制所有依赖程序集。

完整的 Web 应用程序输出是一个包含 *.aspx、.js、web.config、bin\.dll 文件等的站点。要使其复制到您的 c:\binaries 目录,请指定 OutDir。但结果是,您将在路径 c:\binaries\_PublishedWebsites\WebApplication1 下获得完整站点。并且_PublishedWebsites子文件夹无法重命名。

看来这个默认行为是非常严格的。您可以在 C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets 中查看构建目标的内部结构。

编辑:如果你真的不想看到 bin 目录,只需在 svn/git/... 中忽略它。

Your web app has default output path the same as the webapplication1 project dir. Bin catalog is used internally by your site to find where dependent assemblies are (see probing). By Default Microsoft.Web.Publishing.targets uses it to copy all dependent asseblies locally.

Full web app output is a site with *.aspx, .js, web.config, bin\.dll-files and so on. To make it copy to your c:\binaries directory specify OutDir instead. But as a result you will get the full site under the path c:\binaries\_PublishedWebsites\WebApplication1. And _PublishedWebsites subfolder couldn't be renamed.

It seems that this default behaviour is very strict. You can see internals of build targets at C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets.

EDIT: If you really don't want to see bin catalog just ignore it in svn/git/... .

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