【问题标题】:dll.refresh with devenv vs msbuild (Website Project, not application)dll.refresh 与 devenv vs msbuild(网站项目,而不是应用程序)
【发布时间】:2015-04-09 14:58:06
【问题描述】:

我正在为我们的应用程序创建 CI 服务器,但在我们的网站项目中遇到了 msbuild 问题。它构建了一个解决方案,但没有 proj 文件(因为它不是网站应用程序,不能)。 MSBuild 不会将 dll.refresh 文件拉入 bin 文件夹。 (不特定于 CI 问题,但这是目标)如果我针对 devenv.com(CLI 尝试)运行它来构建,那么它确实会拉入 dll.refresh 并且看起来工作得很好。

从我在 MsBuild 日志中可以找到的内容来看,在查找 DLL 文件时,复制任务(这只是 msbuild 本身的默认规则)似乎不是以 /bin 文件夹为目标,而是以解决方案的根目录为目标(在这种情况下是 /www)。

只是在寻找更多信息,因为此时所有其他研究点似乎都枯竭了。 (它必须是 Msbuild 吗?不,但我想让 CI 配置非常简单,其他任何人都可以重新生成,自定义构建脚本/批处理文件和 VS 安装在 CI 服务器上会使它变得更加复杂) .

谢谢。

【问题讨论】:

    标签: visual-studio msbuild continuous-integration


    【解决方案1】:

    我无法重现您使用 VS2013 / MSBuild 12.0.31101.0 描述的行为。

    复制:

    1. 在 VS 中创建新网站
    2. 添加对磁盘上程序集的引用
    3. 清理除*.refresh之外的所有文件的bin目录
    4. 全部保存
    5. 运行msbuild WebsiteSolution.sln

    结果:*.refresh 中引用的 DLL 被重新创建。

    对生成的 MSBuild 文件的通读显示,*.refresh 文件中的路径是相对于网站的基本目录进行解析的。我会注意到这只发生在Build 目标上,所以当您说“复制任务 [...] 是默认规则”时,我不知道您的意思。也许您正在使用一些需要包含默认目标的自定义 MSBuild 目标?

    生成的MSBuild的相关部分(用MSBuildEmitSolution=1生成):

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
      <PropertyGroup>
        <!-- Edit: Snipped -->
        <!-- The website location is stored relative to the .sln -->
        <!-- (which is the same as the location of the temporary msbuild file) -->
        <Project_[...]_AspNetPhysicalPath>..\..\WebSites\WebSite1\</Project_[...]_AspNetPhysicalPath>
        <!-- Edit: Snipped -->
      </PropertyGroup>
      <ItemDefinitionGroup />
      <!-- Edit: Snipped -->
      <Target Name="Build" Condition=" ('$(CurrentSolutionConfigurationContents)' != '') and (false or ( ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ) or ( ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') )) " DependsOnTargets="GetFrameworkPathAndRedistList">
        <!-- Edit: Snipped -->
        <!-- *.refresh items are discovered and saved in [...]_References_RefreshFile -->
        <CreateItem Include="$(Project_[...]_AspNetPhysicalPath)\Bin\*.refresh">
          <Output TaskParameter="Include" ItemName="Project_[...]_References_RefreshFile" />
        </CreateItem>
        <!-- The contents of the *.refresh are read to [...]_References_ReferenceRelPath -->
        <ReadLinesFromFile Condition=" '%(Project_[...]_References_RefreshFile.Identity)' != '' " File="%(Project_[...]_References_RefreshFile.Identity)">
          <Output TaskParameter="Lines" ItemName="Project_[...]_References_ReferenceRelPath" />
        </ReadLinesFromFile>
        <!-- Those contents are relative to [...]_AspNetPhysicalPath -->
        <CombinePath BasePath="$(Project_[...]_AspNetPhysicalPath)" Paths="@(Project_[...]_References_ReferenceRelPath)">
          <Output TaskParameter="CombinedPaths" ItemName="Project_[...]_References" />
        </CombinePath>
        <!-- This seems to be a no-op, since you cannot copy if it doesn't exist -->
        <Copy Condition="!Exists('%(Project_[...]_References.Identity)')" ContinueOnError="true" SourceFiles="@(Project_[...]_References->'%(FullPath)')" DestinationFolder="$(Project_[...]_AspNetPhysicalPath)\Bin\" />
        <!-- Edit: Snipped -->
        <!-- This will copy [...]_References to [...]_References_CopyLocalFiles and add references -->
        <ResolveAssemblyReference Condition="Exists('%(Project_[...]_References.Identity)')" Assemblies="@(Project_[...]_References->'%(FullPath)')" TargetFrameworkDirectories="$(Project_[...]__TargetFrameworkDirectories)" FullFrameworkFolders="$(Project_[...]__FullFrameworkReferenceAssemblyPaths)" SearchPaths="{RawFileName};{TargetFrameworkDirectory};{GAC}" FindDependencies="true" FindSatellites="true" FindSerializationAssemblies="true" FindRelatedFiles="true" TargetFrameworkMoniker=".NETFramework,Version=v4.5">
          <Output TaskParameter="CopyLocalFiles" ItemName="Project_[...]_References_CopyLocalFiles" />
        </ResolveAssemblyReference>
        <!-- [...]_References_CopyLocalFiles is copied to the bin directory -->
        <Copy Condition="(false) or ('$(AspNetConfiguration)' == 'Debug') or ('$(AspNetConfiguration)' == 'Release')" SourceFiles="@(Project_[...]_References_CopyLocalFiles)" DestinationFiles="@(Project_[...]_References_CopyLocalFiles->'$(Project_[...]_AspNetPhysicalPath)\Bin\%(DestinationSubDirectory)%(Filename)%(Extension)')" />
        <!-- Edit: Snipped -->
      </Target>
      <!-- Edit: Snipped -->
    </Project>
    

    我没有在没有安装 VS 的机器上尝试过这个,所以它可能不能直接应用,但是即使没有安装 Visual Studio,你也应该可以使用生成的 metaproj 文件进行构建。

    【讨论】:

    • 我会接受这个作为答案,当我深入研究这个问题时,我发现我们的解决方案文件已损坏/错误。除了 *.refresh 文件,如果您将现有项目添加到解决方案并引用,那么您的解决方案文件将具有 GUID 引用,您不需要 *.refresh 文件。谢谢。
    【解决方案2】:

    我也有这个问题;问题实际上是我们的构建配置既不是 Debug 也不是 Release,所以 msbuild 实际上跳过了编译(因此使用 *.refresh 进行恢复):

    跳过,因为此网站不支持“开发”配置 项目。您可以使用 AspNetConfiguration 属性来覆盖 用于构建 Web 项目的配置,通过添加 /p:AspNetConfiguration= 到命令行。目前网络 项目仅支持 Debug 和 Release 配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-29
      • 2010-11-06
      • 2011-02-03
      • 1970-01-01
      • 2010-10-03
      • 1970-01-01
      • 2010-12-08
      相关资源
      最近更新 更多