-
Notifications
You must be signed in to change notification settings - Fork 82
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
[NoTargets] Can't build with BuildProjectReferences=false when referencing a multi-targeted project #427
Comments
Have you tried @benjamin-hodgson changing MSBuildSdks/src/NoTargets/Sdk/Sdk.targets Line 18 in b54b4a1
|
@stan-sz Doesn't help - happens with both |
The NoTargets SDK by default doesn't reference output assemblies of dependencies. You can change that behavior by setting That's by design as a NoTargets SDK doesn't require output assemblies from dependencies as it doesn't invoke the compiler. |
@ViktorHofer I know that. I'm not expecting any particular behaviour regarding the assemblies themselves but I do expect to be able to run a build in this example. |
Then you probably also understand that the error happens because the
Changing that default would definitely be a major breaking change for NoTargets msbuild SDK consumers. AFAIK referencing a multi-targeting project from a NoTargets SDK project isn't the norm. There is also the Traversal SDK which has some overlap with the NoTargets SDK. |
What makes you say that? Perhaps it'd help for me to explain our use-case: we use <Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup>
<!-- ensure libraries are built before we deploy them -->
<ProjectReference Include="path/to/library1.csproj" />
<ProjectReference Include="path/to/library2.csproj" />
<PackageReference Include="SomePackage" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup>
<Artifact Include="path/to/library1/bin/release/net472/library1.dll" />
<Artifact Include="path/to/library2/bin/release/net472/library2.dll" />
<Artifact Include="$(PkgSomePackage)/lib/netstandard2.0/SomePackage.dll" />
</ItemGroup>
</Project> We build these artifacts in a variety of different configurations for a variety of different environments, including different .NET versions, so there are a number of such So for my purposes I don't really care whether the output assemblies are referenced or whether TF negotiation happens at all, I'm just using the I understand that requiring the Either way, from the perspective of an SDK user (especially one who is not a build expert) this does look like a legit bug - a normal-looking project fails to build with an arcane error message mentioning an internal target. Would it at least be an option to emit a better error message? |
PS I haven't got a minimal repro right now but I suspect this bug also affects transitive project references to multitargeted projects (harder to work around on the downstream end) |
I'm also going to push back against NoTargets projects referencing multitarget projects being uncommon. My NoTargets project intends to ensure dependent projects are up-to-date (but doesn't care about compatibility), and then will create a NuGet package using the outputs. What I think I really want is dotnet/msbuild#4795, and for that to work when used inside a NoTargets project. |
Summary
When referencing a multi-targeted project from a
NoTargets
project, you can't build withBuildProjectReferences=false
.Repro
library\library.csproj
:deployment\deployment.proj
:Other details
Setting
SkipGetTargetFrameworkProperties=false
on theProjectReference
fixes the problem. The culprit appears to be this line, but I'm not sure what the impact of removing that would be.This came up because QuickBuild (MS internal build tool for large repos) invokes MSBuild with
BuildProjectReferences=false
.The text was updated successfully, but these errors were encountered: