You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And the target is implemented in Directory.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:
The build is working if the project doesn't use transitive nuget packages in the referenced project with ProjectReference. If the project uses nuget packages included in the referenced project with ProjectReference, then build fails. Normally, if we set ProjectReference 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 added ProjectReference.
The intellisense and solution explorer doesn't see the ProjectReference nor PackageReference according to UseLocalNuGetProjects property.
How can I solve these two problems?
By the way I've tried many targets in BeforeTargets like ResolveProjectReferencesDesignTime2, CompileDesignTime, ResolveProjectReferences, ResolvePackageDependencies, Compile, etc, but no luck.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm trying to add
ProjectReference
orPackageReference
on a condition with a target. I have csproj files including these:The condition property is set in
Directory.Build.props
:And the target is implemented in
Directory.Build.targets
:I have 2 problem with this approach:
ProjectReference
. 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
.ProjectReference
norPackageReference
according toUseLocalNuGetProjects
property.How can I solve these two problems?
By the way I've tried many targets in
BeforeTargets
likeResolveProjectReferencesDesignTime2
,CompileDesignTime
,ResolveProjectReferences
,ResolvePackageDependencies
,Compile
, etc, but no luck.Best Regards.
Beta Was this translation helpful? Give feedback.
All reactions