Visual Studio网站参考路径

时间:2008-11-10 22:44:41

标签: visual-studio version-control

在Visual Studio网站项目中(在Visual Studio 2005或更高版本中,而不是仍存在.csproj文件的Web应用程序项目)如何存储参考信息,并且可以在不将源编译的二进制文件存储在源中的情况下对其进行源控制控制?

如果右键单击网站项目并选择“属性页”,则第一个屏幕(引用)将列出所有项目引用。

System。*引用列为GAC类型,其他DLL文件可以列为BIN或Project。

当您将某些内容包含为项目引用,然后将其提交给源代码控制(对于我们,Subversion,忽略.dll和.pdb文件)时会出现问题。

另一个开发人员从存储库中获取更新的代码,并且必须手动设置所有这些项目引用,但我甚至无法确定此信息的存储位置,除非它位于.suo中,这不是源代码控制友好的

3 个答案:

答案 0 :(得分:18)

如果您通过浏览选项卡引用.dll文件名,则应该创建一个.refresh文件(嵌套在BIN中的dll下)。我们将它们放在SVN中并且效果很好(您可能需要手动编辑它们以使用相对路径)。

从.NET选项卡添加的引用将添加到web.config

项目引用存储在解决方案(.sln)文件中。打开.sln文件,你会看到它们列出:

Project("{xxxxxxx-7377-xxxx-xxxx-BC803B73C61A}") = "XXXXXXX.Web", "XXXXXXX.Web", "{xxxxxxxx-BB14-xxxx-B3B6-8BF6D8BC5AFF}"
    ProjectSection(WebsiteProperties) = preProject
        TargetFramework = "3.5"
        ProjectReferences = "{xxxxxxxx-C3AB-xxxx-BBED-2055287036E5}|XXXXXX.Data.dll;
            ...

答案 1 :(得分:16)

Visual Studio中的“Web站点”项目是一件奇怪的事情。它们似乎是为了迎合传统的Web开发人员,其中“站点”只是目录中的一组文件。以同样的方式,当你在Visual Studio中创建一个“Web站点”项目时,没有真正的“项目”文件,比如C#项目有一个.csproj文件。但是,仍然存在解决方案文件(.sln)。通常,程序集.dll引用保存在项目文件中。由于网站没有网站,他们去哪里了?

对其他项目的引用

如果添加对另一个项目的引用,则会在解决方案.sln文件中生成一个条目。最终看起来像这样:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite1", "..\..\WebSites\WebSite1\", "{F25DB9D6-810D-4C18-ACBB-BFC420D33B20}"
ProjectSection(WebsiteProperties) = preProject
TargetFramework = "3.5"
ProjectReferences = "{11666201-E9E8-4F5A-A7AB-93D90F3AD9DC}|ClassLibrary1.dll;"

文件系统参考

如果浏览文件系统并添加.dll文件,则Visual Studio将在\ Bin文件夹中创建一个名称相同的“.refresh”文件。此文件只是一行文本文件,指示文件的加载路径。例如,如果我从.... \ libs添加“MyAssem.dll”,那么在Web Site \ Bin文件夹中,我最终会复制2个文件:MyAssem.dll和MyAssem.dll.refresh。 .refresh文件将包含文本:“.... \ libs”。在每次构建时,Visual Studio将检查.refresh文件中的路径,如果存在较新的.dll,它将覆盖Bin目录中的那个。

警告:如果.refresh文件告诉它看起来不存在该文件,Visual Studio将不会抛出错误。它将继续使用\ Bin文件夹中已有的.dll。但是会输出警告。

GAC参考

如果从全局程序集缓存添加程序集,Visual Studio将在Web.config文件中输入它,如下所示:

<compilation debug="false">
 <assemblies>
  <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

此外,您需要注意的是Visual Studio假定如果程序集位于开发计算机上的GAC中,那么它将在运行时位于同一位置!如果您的开发计算机上安装了Oracle.DataAccess,这可能会让您遇到麻烦,这会将其置于GAC中,但在部署时,您只需将.dll复制到生产计算机上。它仍然会尝试在GAC中找到它并且可能在运行时失败。

我希望这有助于清理奇怪的网站以及引用如何工作!

答案 2 :(得分:0)

我使用copyprojectDll.ps1 powershell。

我的文件夹结构在

下面
  • ClassLibraries
    第三方
    网站/斌
    CopyprojectDll.ps1
    Website.sln

ClassLibraries是我的项目的代码类,DAL .. 网站项目仅包含web文件,aspx,aspx.cs .. ThirdParty是必需的库,AjaxToolkit等。

我编译了ClassLibraries.sln 我运行CopyprojectDll.ps1 之后我使用Website.sln。

示例powershell文件位于下方。

$ folders = @(); $ folders + =“IB.Security” $ folders + =“ClassLibraries / Core.Classes”

function CopyDllsToWebBin($ dll_files) {   if($ dll_files -eq $ null)   {     返回;   } $ targetfolder =“./ Kod/bin /”

foreach($dll in $dll_files)
{

    copy-item $dll.FullName -destination "$targetfolder" -force #-Verbose
}

}

function CopyDllsToThirdParty($ dll_files) {

$ targetfolder =“./ ThirdParty /”

foreach($dll in $dll_files)
{
    copy-item $dll.FullName -destination "$targetfolder" -force #-Verbose
}

}

$ dll_output_folder =“/ bin / debug”;

foreach($文件夹中的$文件夹) {     $ dll_files = Get-ChildItem -Path $ folder $ dll_output_folder -include * .dll -Recurse | sort-object名称     CopyDllsToWebBin($ dll_files)     $ dll_files = Get-ChildItem -Path $ folder $ dll_output_folder -include * .pdb -Recurse | sort-object名称     CopyDllsToWebBin($ dll_files)     $ dll_files = Get-ChildItem -Path $ folder $ dll_output_folder -include * .xml -Recurse | sort-object名称     CopyDllsToWebBin($ dll_files)    “复制$ folder $ dll_output_folder”

}

$ dll_files = Get-ChildItem -Path“ThirdParty”-include * .dll -Recurse | sort-object名称 CopyDllsToWebBin($ dll_files) $ dll_files = Get-ChildItem -Path“ThirdParty”-include * .pdb -Recurse | sort-object名称 CopyDllsToWebBin($ dll_files) $ dll_files = Get-ChildItem -Path $ folder $ dll_output_folder -include * .xml -Recurse | sort-object名称 CopyDllsToWebBin($ dll_files)

“复制的ThirdParty”

日期