【问题标题】:MSBuild not finding the DLLMSBuild 找不到 DLL
【发布时间】:2021-11-11 20:01:50
【问题描述】:

我使用Mono.Cecil 发出一个控制台应用程序,并且我想将 MSBuild 集成到构建过程中。但是当我在我的自定义项目文件上运行dotnet build 时,MSBuild 会抛出一个错误说Expected file "obj\Debug\net5.0\refint\test.dll" does not exist。它试图在refint 文件夹中找到生成的程序集。当程序集在obj\Debug\net5.0\test.dll 内生成时,它应该是。有没有办法可以更改 MSBuild 查找输出程序集的路径? IL 生成器方面的所有内容都可以正常工作,我什至在 build 文件夹中获得了一个可运行的 exe。这是我的项目文件:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <DefaultLanguageSourceExtension>.ao</DefaultLanguageSourceExtension>
    <OutputPath>C:\Users\filip\source\alto\samples\test\obj\Debug\net5.0\</OutputPath>
  </PropertyGroup>

  <Target Name="CreateManifestResourceNames" />

  <Target Name="CoreCompile" DependsOnTargets="$(CoreCompileDependsOn)">
    <Exec Command="dotnet run --project &quot;$(MSBuildThisFileDirectory)\..\..\src\aoc\aoc.csproj&quot; -- @(Compile->'$(MSBuildThisFileDirectory)', ' ') /o &quot;@(IntermediateAssembly)&quot; @(ReferencePath->' /r &quot;%(Identity)&quot;', ' ')"
          WorkingDirectory="$(MSBuildProjectDirectory)" />
  </Target>

</Project>

提前谢谢你。

【问题讨论】:

  • IntermediateOutputPath 包含输出文件夹的路径,例如`obj\debug\net5.0`。您应该更新此属性
  • IntermediateOutputPath 不是问题所在。它被设置为正确的路径。我想出了一个解决方案。

标签: msbuild


【解决方案1】:

我没有阅读完整的错误信息。

C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\Microsoft.Common.CurrentVersion.targets(4527,5): error : Expected file "obj\Debug\net5.0\refint\test.dll" does not exist.

它实际上将我指向一个引发错误的文件。这是哪里:

<!-- Copy the reference assembly build product (.dll or .exe). -->
    <CopyRefAssembly
        SourcePath="@(IntermediateRefAssembly)"
        DestinationPath="$(TargetRefPath)"
        Condition="'$(ProduceReferenceAssembly)' == 'true' and '$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'"
            >

      <Output TaskParameter="DestinationPath" ItemName="ReferenceAssembly"/>
      <Output TaskParameter="DestinationPath" ItemName="FileWrites"/>

    </CopyRefAssembly>

当我不需要时,它会尝试制作一个参考程序集。所以我只是将ProduceReferenceAssembly 属性设置为false,因为我不需要。

【讨论】:

    猜你喜欢
    • 2011-08-04
    • 1970-01-01
    • 2011-09-20
    • 2013-05-27
    • 2012-07-25
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多