Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Target which adds ProjectReference or PackageReference on a condition#11191

Unanswered
oruchreis asked this question inQ&A
Discussion options

Hi,
I'm trying to addProjectReference orPackageReference on a condition with a target. I have csproj files including these:

<CustomReferenceInclude="Package1" /><CustomReferenceInclude="Package2" />

The condition property is set inDirectory.Build.props:

<PropertyGroup>  <UseLocalNuGetProjectsCondition="'$(UseLocalNuGetProjects)' == ''">true</UseLocalNuGetProjects>

And the target is implemented inDirectory.Build.targets :

<Project>  <TargetName="ResolveCustomeReferences"BeforeTargets="BeforeBuild;ResolveReferences">    <ItemGroupCondition="'@(CustomReference.Identity)' != ''">      <MSBuildProjects="$(MSBuildThisFileDirectory)Libraries/%(CustomReference.Identity)/%(CustomReference.Identity).csproj"Targets="Restore;Build"Condition="'$(UseLocalNuGetProjects)' == 'true'" />      <ProjectReferenceInclude="$(MSBuildThisFileDirectory)Libraries/%(CustomReference.Identity)/%(CustomReference.Identity).csproj"Condition="'$(UseLocalNuGetProjects)' == 'true'"IncludeAssets="all" />            <PackageReferenceInclude="@(CustomReference)"Condition="'$(UseLocalNuGetProjects)' != 'true'" /><!-- I have also Directory.Packages.props so I don't need version in PackageReference in the target.-->    </ItemGroup>  </Target></Project>

I have 2 problem with this approach:

  1. The build is working if the project doesn't use transitive nuget packages in the referenced project withProjectReference. If the project uses nuget packages included in the referenced project withProjectReference, then build fails. Normally, if we setProjectReference statically in the csproj, we can use transitive nuget packages in that reference, but I couldn't overcome the unresolved nuget package errors with above dynamically addedProjectReference.
  2. The intellisense and solution explorer doesn't see theProjectReference norPackageReference according toUseLocalNuGetProjects property.

How can I solve these two problems?

By the way I've tried many targets inBeforeTargets likeResolveProjectReferencesDesignTime2,CompileDesignTime,ResolveProjectReferences,ResolvePackageDependencies,Compile, etc, but no luck.

Best Regards.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@oruchreis

[8]ページ先頭

©2009-2025 Movatter.jp