Rich T.
Rich T.

Reputation: 110

Teamcity .Net project, conditional project reference when building in Visual Studio

I have build chains in TeamCity, where the dependent artifact is copied to /bin directory of the main project. The project file references the artifact. That all works.

What I want is to allow a project file include, instead of the binary reference, when building/debugging from Visual Studio. I have tried some approaches, such as using conditionals in the project file, but is there a nice clean way to approach this?

Upvotes: 0

Views: 201

Answers (1)

JGooLaaR
JGooLaaR

Reputation: 94

May be there is the part of solution. May way of using several referencing types of projs.

  <ItemGroup Condition=" '$(ReferencedDACPAC)' == '' ">
    <ProjectReference Include="..\OmniUS\OmniUS.sqlproj">
      <Name>OmniUS</Name>
      <Project>{26075a62-f6b0-40c3-baa2-b9a9829da3c4}</Project>
      <Private>False</Private>
      <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors>
    </ProjectReference>
    <ProjectReference Include="..\OmniUS_Finance_Jural\OmniUS_Finance_Jural.sqlproj">
      <Name>OmniUS_Finance_Jural</Name>
      <Project>{c8b0aee7-c2a4-4370-8451-13b455bb5363}</Project>
      <Private>False</Private>
      <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors>
    </ProjectReference>
  </ItemGroup>
  <ItemGroup Condition=" '$(ReferencedDACPAC)' == 'true' ">
    <ArtifactReference Include="..\DacPacs\OmniUS.sqlproj.dacpac">
      <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors>
    </ArtifactReference>
    <ArtifactReference Include="..\DacPacs\OmniUS_Finance_Jural.sqlproj.dacpac">
      <SuppressMissingDependenciesErrors>False</SuppressMissingDependenciesErrors>
    </ArtifactReference>
  </ItemGroup>

When I build in TeamCity, I send ReferencedDACPAC as the "System" variable in the build, and thus refer to "ArtifactReference". When i build in VisualStudio, there is no var and the referencing occurs as "ProjectReference".

Upvotes: 1

Related Questions