Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectReference does not import build.props/build.targets to like PackageReference does #35704

Closed
dameng324 opened this issue Sep 25, 2023 · 5 comments
Assignees
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@dameng324
Copy link
Contributor

I'm working on NativeAOT with reflection using Rd.xml.
I create a library project named Plugin . in the project I create build directory and Plugin.props and Plugin.Rd.xml in it and pack it in to package like this:
Plugin.csproj

<ItemGroup>
  <Content Include="build\*.*">
	  <Pack>true</Pack>
	  <PackagePath>build;</PackagePath>
  </Content>
</ItemGroup>

build/Plugin.props

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <ItemGroup>
	  <RdXmlFile Include="$(MSBuildThisFileDirectory)Plugin.Rd.xml"/>
  </ItemGroup>
</Project>

build/Plugin.Rd.xml

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
	<Application>
		<Assembly Name="Plugin">
			<Type Name="Plugin.UseReflectionClass" Dynamic="Required All"/>
		</Assembly>
	</Application>
</Directives>

If I pack Plugin to a nuget package, and use <ProjectReference Include="..\Plugin\Plugin.csproj" /> to reference it, It works correctly, I can publish my exe to native aot and use the RdXmlFile what Plugin project specified with no more configuration.
But when I directly use ProjectReference like <ProjectReference Include="..\Plugin\Plugin.csproj" /> in my exe project, It does not work. It looks like does not import the build/Plugin.props to my exe project.

Create a new nuget package every time library project changed code is too much trouble, how to use ProjectReference behave like PackageReference?

@ghost ghost added the untriaged Request triage from a team member label Sep 25, 2023
@ghost
Copy link

ghost commented Sep 25, 2023

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

I'm working on NativeAOT with reflection using Rd.xml.
I create a library project named Plugin . in the project I create build directory and Plugin.props and Plugin.Rd.xml in it and pack it in to package like this:
Plugin.csproj

<ItemGroup>
  <Content Include="build\*.*">
	  <Pack>true</Pack>
	  <PackagePath>build;</PackagePath>
  </Content>
</ItemGroup>

build/Plugin.props

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <ItemGroup>
	  <RdXmlFile Include="$(MSBuildThisFileDirectory)Plugin.Rd.xml"/>
  </ItemGroup>
</Project>

build/Plugin.Rd.xml

<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
	<Application>
		<Assembly Name="Plugin">
			<Type Name="Plugin.UseReflectionClass" Dynamic="Required All"/>
		</Assembly>
	</Application>
</Directives>

If I pack Plugin to a nuget package, and use <ProjectReference Include="..\Plugin\Plugin.csproj" /> to reference it, It works correctly, I can publish my exe to native aot and use the RdXmlFile what Plugin project specified with no more configuration.
But when I directly use ProjectReference like <ProjectReference Include="..\Plugin\Plugin.csproj" /> in my exe project, It does not work. It looks like does not import the build/Plugin.props to my exe project.

Create a new nuget package every time library project changed code is too much trouble, how to use ProjectReference behave like PackageReference?

Author: dameng324
Assignees: -
Labels:

area-Infrastructure-libraries

Milestone: -

@ViktorHofer ViktorHofer transferred this issue from dotnet/runtime Sep 25, 2023
@ViktorHofer
Copy link
Member

ViktorHofer commented Sep 25, 2023

Unsure if dotnet/sdk is the right repository. Maybe NuGet or msbuild is a better place?

@dameng324
Copy link
Contributor Author

I found a similar issue In Nuget repo NuGet/Home#6624 but it's 5 years before and not solved. I think feedback should not helpful there.

@ViktorHofer
Copy link
Member

ViktorHofer commented Oct 26, 2023

Yes, we have several issues requesting this type of feature: NuGet/Home#6624, dotnet/msbuild#5797

As mentioned here I believe this could work as we already require an additional evaluation pass for restore which could then import these files to subsequent evaluations. It's probably a matter of priority, cost and the potential of breaking existing customers.

I would love to see such a feature.

@dameng324
Copy link
Contributor Author

Hope to see such a feature too. I have already use DynamicDependencyAttribute to solve my nativeAOT problem. so this issue does not affect me now. You can close this issue as you want.

@rainersigwald rainersigwald closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

4 participants