Clojure Msbuild将项目引用解析为自定义项目类型

Clojure Msbuild将项目引用解析为自定义项目类型,clojure,msbuild,Clojure,Msbuild,我已经为一种叫做clojure的编程语言创建了一个自定义项目类型(cljproj而不是csproj)。当项目编译时,它会输出多个.dll文件以及一些依赖的.clj文件 这是通过覆盖cljproj文件中的默认CoreCompile目标来实现的。它基本上将所有需要编译的文件复制到bin目录,然后执行一个单独的应用程序来编译它们 <Target Name="CoreCompile"> <PropertyGroup> <ClojureNamespaces>

我已经为一种叫做clojure的编程语言创建了一个自定义项目类型(cljproj而不是csproj)。当项目编译时,它会输出多个.dll文件以及一些依赖的.clj文件

这是通过覆盖cljproj文件中的默认CoreCompile目标来实现的。它基本上将所有需要编译的文件复制到bin目录,然后执行一个单独的应用程序来编译它们

<Target Name="CoreCompile">
  <PropertyGroup>
    <ClojureNamespaces>@(Compile -> '%(RelativeDir)%(Filename)', ' ')</ClojureNamespaces>
  </PropertyGroup>
  <Copy SourceFiles="@(Compile)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" DestinationFiles="@(Compile -> '$(OutDir)%(RelativeDir)%(Filename)%(Extension)')" />
  <Exec WorkingDirectory="$(OutDir)" Command="&quot;$(ClojureRuntimesDirectory)\$(ClojureVersion)\Clojure.Compile&quot; $(ClojureNamespaces.Replace('\', '.'))" />
</Target>

@(编译->“%”(RelativeDir)%(文件名)“,”)
我在clojure项目(cljproj)中添加了一个来自c#项目(csproj)的引用


{8fe1995b-4b6d-4911-b563-a759467fdf53}
Clojure ASP.Net MVC控制器库1
默认情况下,Visual Studio无法正确解析项目引用,因为它假定只有一个输出,即Clojure ASP.Net MVC Controller Library1.dll。 实际输出文件的示例有MVCAPApplication1.Controllers.HomeController.dll和HomeController.clj

我希望在不更改C#.csproj文件的情况下完成这项工作,以便可以轻松地从任何.csproj文件引用.cljproj

我试图通过覆盖GetTargetPath目标来解析项目引用

<Target Name="GetTargetPath" DependsOnTargets="$(GetTargetPathDependsOn)" Returns="@(TargetPath)">
  <ItemGroup>
    <TargetPath Include="$(TargetDir)\**\*.dll" />
    <!-- <TargetPath Include="$(TargetDir)\**\*.clj" /> -->
  </ItemGroup>
</Target>

如果我使用*.dll设置TargetPath,它会工作并将.dll文件复制到c#.csproj输出目录。它甚至将.pdb文件复制到该目录,尽管我没有将它们添加到TargetPath。但是,如果我取消对*.clj TargetPath的注释,CSC会抱怨.clj文件已损坏(可能是因为它们是纯文本,而不是.net程序集)


我很乐意使用copy命令而不是重写TargetPath,但是我不确定将它们输出到哪个目录变量,因为$(outdir)给我的是自定义项目(.cljproj)的bin,而不是试图解析项目引用(.csproj)的c#项目的bin。我不确定除了GetTargetPath之外还要覆盖哪个目标,因为大多数clojure项目(.cljproj)目标在编译c#(.csjproj)项目时都不会被调用,例如:.cljproj:AfterBuild仅在直接编译cljproj时被调用,不是在编译.csproj时,它有一个对.cljproj的项目引用。

我能够通过覆盖GetCopyToOutputDirectoryItems目标使它工作

<Target Name="GetCopyToOutputDirectoryItems" Returns="@(CopyToOutputDirectoryItemsWithTargetPath)">
  <ItemGroup>
    <CopyToOutputDirectoryItems Include="$(TargetDir)\**\*.clj">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </CopyToOutputDirectoryItems>
  </ItemGroup>
  <AssignTargetPath Files="@(CopyToOutputDirectoryItems)" RootFolder="$(TargetDir)">
    <Output TaskParameter="AssignedFiles" ItemName="CopyToOutputDirectoryItemsWithTargetPath" />
  </AssignTargetPath>
</Target>

保存最新
<Target Name="GetCopyToOutputDirectoryItems" Returns="@(CopyToOutputDirectoryItemsWithTargetPath)">
  <ItemGroup>
    <CopyToOutputDirectoryItems Include="$(TargetDir)\**\*.clj">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </CopyToOutputDirectoryItems>
  </ItemGroup>
  <AssignTargetPath Files="@(CopyToOutputDirectoryItems)" RootFolder="$(TargetDir)">
    <Output TaskParameter="AssignedFiles" ItemName="CopyToOutputDirectoryItemsWithTargetPath" />
  </AssignTargetPath>
</Target>