Web 部署项目是否适用于 x86 构建配置

发布于 2024-09-05 01:02:30 字数 987 浏览 4 评论 0原文

我需要构建一个网站和它在 x86 配置中引用的几个 DLL。迄今为止,我们一直在使用 Web 部署项目来创建结果站点的 Zip 文件及其所需的所有文件。我们需要继续使用 WDP,但是它们似乎在 x86 构建配置方面存在问题。

在我的项目中,当我在 Release/x86 中构建解决方案时,出现以下错误。

           Description                              File                           Line   Column   Project
Error  80  Could not load type 'WwwRooot.Default'.  /WwwRooot.csproj/Default.aspx  1      1        WwwRooot.csproj_deploy

Web 应用程序或任何引用的类库没有生成错误或警告。

我认为这可能是我正在从事的项目所特有的,所以为了证明自己是错的,我创建了一个包含 Web 应用程序 (c#) 的解决方案。然后,我使用配置管理器通过复制任何 CPU 配置来创建 x86 配置。我检查了属性页面,确保新配置已设置为构建为 x86,确实如此。我构建的解决方案没有错误。

接下来,我右键单击 Web 应用程序并从上下文菜单中添加了 WDP。 右键单击 WDP 并编辑项目文件。此时,我将 AnyCPU 的所有引用更改为 x86,以便 WDP 具有 x86 构建的条件。 我在 Release/x86 中重建了解决方案,一切都构建得很好。

接下来,我添加一个类库,使用配置管理器为此库创建 x86 配置,添加对该库的 Web 应用程序的引用,然后在 Release/x86 中重建所有内容,我收到与上面详述的相同的错误。

WDP 是否与 x86 版本兼容?

如果我删除类库(和引用),则解决方案(包括 WDP)可以正常构建。

我在 64 位 Windows 7 Pro 上使用 Visual Studio 2008 SP1,并安装了适当的 WDP。

I have a need to build a website and several DLLs that it references in an x86 configuration. To date we have been using Web Deployment Projects to create Zip files of the resultant site and all it's required files. We need to continue to use WDPs however, they seem to have problems with the x86 build configuration.

In my project, when I build the solution in Release/x86 I get the following error.

           Description                              File                           Line   Column   Project
Error  80  Could not load type 'WwwRooot.Default'.  /WwwRooot.csproj/Default.aspx  1      1        WwwRooot.csproj_deploy

There are no build errors or warnings from the web application or any of the referenced class libraries.

I thought this might be something specific to the project I'm working on so to prove myself wrong I created a solution containing a Web Application (c#). I then used the Configuration Manager to create the x86 configuration by copying the Any CPU config. I checked the properties page an made sure the new config was set to build to x86, and it was. I built the solution without error.

Next I right clicked the Web App and added a WDP from the context menu.
Right clicked on the WDP and edited the project file. At this point I changed any references for AnyCPU to x86 so that the WDP has conditions of x86 build.
I rebuilt the solution in Release/x86 and everything builds fine.

Next I add a Class Library, use Configuration Manager to create an x86 config for this library, add a reference to the web app for the library and then rebuild all in Release/x86 and I receive the same error as detailed above.

Are WDPs compatible with x86 build?

If I remove the Class Library (and the reference) the solution (including the WDP) builds fine.

I am using Visual Studio 2008 SP1, with the appropriate WDPs installed, on 64Bit Windows 7 Pro.

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

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

发布评论

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

评论(2

暖伴 2024-09-12 01:02:30

开箱即用的 Web 部署项目 (WDP) 不适用于 x86 或 x64 构建配置。这是因为在其中一种配置下构建的 Web 应用程序将生成的程序集输出到不同的位置,并且 WDP 不知道在那里查找 DLL。

您需要执行一些操作才能使 WDP 与您的 x86 配置配合使用。

首先,您的 WDP 可能没有 x86 配置,您需要创建一个。使用 Visual Studio 中的 XML 编辑器(或任何文本编辑器)编辑部署项目,在文件顶部附近将看到一个带有条件 标记(通常是第二个) >Debug|AnyCPU 像这样:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>.\Debug</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
  </PropertyGroup>

复制整个标签并将配置更改为 Debug|x84

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>.\Debug</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
  </PropertyGroup>

现在保存文件并打开配置管理器(构建菜单 > 配置管理器)并检查您的部署项目现在是否具有 x86 配置。

现在,使用文本编辑器编辑 Web 应用程序项目文件,并在 Debug|x86 配置中找到 outputPath 元素。它的值应为 Bin\x86\Debug。这需要更改为 Bin

 <!-- Before -->
 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <OutputPath>Bin\x86\Debug\</OutputPath>

 <!-- After -->
 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <OutputPath>Bin\</OutputPath>

保存、关闭并重新加载您的 Web 应用程序项目。现在,我们已指示 Web 应用程序将其 DLL 放置在 WDP 期望找到的位置。

将构建配置设置为 x86 并构建项目。

冲洗并重复发布和您可能拥有的任何其他构建配置。

Out of the box, Web Deployment Projects (WDP) don't work with x86 or x64 build configurations. This is because a Web Application built under one of these configurations outputs the resultant assemblies in a different place and the WDP doesn't know to look there for the DLLs.

There are a few things you'll need to do to get the WDP working with your x86 configuration.

Firstly, your WDP probably doesn't have an x86 configuration, you'll need to create one. Edit the deployment project using the XML editor in Visual Studio (or any text editor), near the top of the file will see a <propertyGroup> tag (usually the second one) with a condition Debug|AnyCPU like so:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>.\Debug</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
  </PropertyGroup>

Duplicate this whole tag and change the configuration to be Debug|x84:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>.\Debug</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
  </PropertyGroup>

Now save the file and open the configuration manager (Build menu > Configuration manager) and check your deployment project now has an x86 configuration.

Now edit the Web Application Project file using your text editor and locate the outputPath element within the Debug|x86 configuration. It should have a value of Bin\x86\Debug. This needs changing to Bin:

 <!-- Before -->
 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <OutputPath>Bin\x86\Debug\</OutputPath>

 <!-- After -->
 <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <OutputPath>Bin\</OutputPath>

Save, close and reload you Web Application Project. We've now instructed the Web Application to put it's DLLs where the WDP expects to find them.

Set your build configuration to x86 and build the project.

Rinse and repeat for Release and any other build configurations you might have.

心舞飞扬 2024-09-12 01:02:30

试试这个

将此命令放入您的 Web 项目的编译后事件中

xcopy "$(TargetDir)*.*" "$(TargetDir)..\..\" /Y

此命令会将文件从 bin\x86\Debug 复制到 bin
它将与发布配置一起使用

Try this

Put this command in post compilation events of your web project

xcopy "$(TargetDir)*.*" "$(TargetDir)..\..\" /Y

This command wil copy files from bin\x86\Debug to bin
It will work with Release configuration

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