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

Disable Project Reference TargetFramework Validation for NoTargets? #191

Closed
TheXenocide opened this issue Jun 19, 2020 · 5 comments · Fixed by #194
Closed

Disable Project Reference TargetFramework Validation for NoTargets? #191

TheXenocide opened this issue Jun 19, 2020 · 5 comments · Fixed by #194
Labels
Bug Something isn't working

Comments

@TheXenocide
Copy link

We have an SDK derived from NoTargets and are trying to use it in the process of creating an installer. Sometimes these projects need to reference net48 projects and sometimes they need to reference netcoreapp2.1 projects. Since our NoTargets-based project isn't compiling anything, but rather copying files/applying scripts/etc. we were hoping to be able to reference without worrying about different target frameworks. To be clear, we're not trying to use multi-targeting with this project, it's goal is to have one output that can reference either or both project types. Is this feasible?

@jeffkl jeffkl added the Bug Something isn't working label Jun 19, 2020
@jeffkl
Copy link
Contributor

jeffkl commented Jun 19, 2020

It probably won't work as-is today but you can try it. I think we need to set these properties on ProjectReference items like we do in Traversal:

<ItemDefinitionGroup Condition=" '$(TraversalDoNotReferenceOutputAssemblies)' != 'false' ">
<ProjectReference>
<!--
Setting ReferenceOutputAssembly skips adding the outputs of the referenced project to an item
-->
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<!--
Setting SkipGetTargetFrameworkProperties skips target framework cross-project validation in NuGet
-->
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
</ProjectReference>
</ItemDefinitionGroup>

@TheXenocide
Copy link
Author

Thanks for the info, we've tentatively worked around things, but we may have a chance to try some of these soon. If I manage to get any additional info on this I'll try to share it here, though admittedly this is being worked on by someone else on the team while I'm focused on other things.

@TheXenocide
Copy link
Author

So it looks like this works for us. Thanks! I can see scenarios that would want to work both ways, so I'm not sure if there's a need to change the default behavior or if easier methods of control are called for, but we actually need some projects to work like normal project references at times so in our case it's actually helpful to be able to apply these on a per-project basis. I don't want to close the ticket in case you guys have ideas on improving the experiences, but I think we're getting what we need out of it with those item properties. Thanks again!

jeffkl added a commit to jeffkl/MSBuildSdks that referenced this issue Jul 14, 2020
Since NoTargets projects don't define runtime requirements like target framework, there is no point in checking compatibility.

Fixes microsoft#191
jeffkl added a commit to jeffkl/MSBuildSdks that referenced this issue Jul 14, 2020
Since NoTargets projects don't define runtime requirements like target framework, there is no point in checking compatibility.

Fixes microsoft#191
jeffkl added a commit that referenced this issue Jul 14, 2020
Since NoTargets projects don't define runtime requirements like target framework, there is no point in checking compatibility.

Fixes #191
@jeffkl
Copy link
Contributor

jeffkl commented Jul 14, 2020

Fix is available here: https://github.com/microsoft/MSBuildSdks/releases/tag/Microsoft.Build.NoTargets.2.0.1

@japj
Copy link
Contributor

japj commented Jul 15, 2020

Note that for MSBuild "Restoring" a NoTargets Sdk Project, a TargetFramework property is still required to be set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants