mic*_*win 33 c# deployment msbuild visual-studio
我有一个Web应用程序项目,它使用一组第三方dll.问题是dev/staging环境是32位,但生产是64位.因此,我们每次要部署时都必须重新引用和构建解决方案.我现在想要自动执行此操作,但不确定如何使用MSBuild进行自动化?
所有其他的dll都是一样的,只有3个第三方dll的.
编辑
我已经取得了一些进展,但是我想出了一些运行时装配问题.
我有3个dll文件,1.dll,2.dll,3.dll.每个文件版本为5.1.对于64位dll,名称完全相同,只是差异文件版本.我所做的,将每个重命名为1.v5.dll,1.v6.dll等.在我的项目文件中,我然后引用每个dll如下:
<Reference Include="1.v5.dll" Condition="'$(Platform)'=='x86'">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\1.v5.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="1.v6.dll" Condition="'$(Platform)'=='x64'">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\1.v6.dll</HintPath>
<Private>False</Private>
</Reference>
Run Code Online (Sandbox Code Playgroud)
这适用于Visual Studio IDE,我的解决方案编译文件,但是当我去运行网站时,我收到以下错误...
"无法加载文件或程序集'1.v5'或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.
有关如何处理此问题的任何想法?
sti*_*ijn 39
您可以在项目文件中创建条件引用,如下所示:
<Reference Include="32bit.dll" Condition="'$(Platform)'=='x86'"/>
<Reference Include="64bit.dll" Condition="'$(Platform)'=='x64'"/>
Run Code Online (Sandbox Code Playgroud)
要在VS中使用此功能,您必须创建两个解决方案平台:一个用于x86目标,另一个用于x64目标.根据活动平台,将选择其中一个dll,无需重新参考.
要使用msbuild自动执行此操作,请创建一个新项目文件,该文件多次构建其他项目文件,每次都用于不同的平台/配置/ ...:
<Target Name="BuildAll">
<MSBuild Targets="myproject.proj" Properties="Platform=x86;Configuration=Debug"/>
<MSBuild Targets="myproject.proj" Properties="Platform=x64;Configuration=Debug"/>
<MSBuild Targets="myproject.proj" Properties="Platform=x64;Configuration=Release"/>
</Target>
Run Code Online (Sandbox Code Playgroud)
查看MSBuild任务参考,了解并行选项等附加选项.
mic*_*win 20
这是我已经想到的,似乎没有问题.
我创建了2个解决方案平台,x86和x64.我在我的解决方案目录中创建了一个名为"References"的新文件夹,并创建了n x86和x64文件夹:\ References\x86\\ References\x64 \然后将每个文件夹的3个dll放在各自的目录中.
在每个项目的文件中,我添加了以下引用:
<Reference Include="{Reference1}" Condition="'$(Platform)'=='x86'">
<HintPath>..\References\dlls\x86\{Reference1}.dll</HintPath>
</Reference>
<Reference Include="{Reference2}" Condition="'$(Platform)'=='x64'">
<HintPath>..\References\dlls\x64\{Reference2}.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
现在,当我在IDE中开发时,我正在处理与我的需求相关的相关dll.
然后我添加了一个post-build事件,它将基于$(Platform)变量的dll复制到bin目录中.
| 归档时间: |
|
| 查看次数: |
20301 次 |
| 最近记录: |