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

Target Segment in . targets file in buildTransitive not work #12223

Closed
Y-Theta opened this issue Nov 9, 2022 · 6 comments
Closed

Target Segment in . targets file in buildTransitive not work #12223

Y-Theta opened this issue Nov 9, 2022 · 6 comments
Labels
Functionality:Restore Resolution:NeedMoreInfo This issue appears to not have enough info to take action Type:Bug WaitingForCustomer Applied when a NuGet triage person needs more info from the OP

Comments

@Y-Theta
Copy link

Y-Theta commented Nov 9, 2022

NuGet Product Used

NuGet.exe

Product Version

nuget.exe 6.3.0.131

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

create a package with struct like
mctech.lib.desktopcapture
-1.4.2
-buildTransitive
-net47
-McTech.Lib.DesktopCapture.targets

and in the targets
have a

   <Target Name="T2"
        AfterTargets="Build">
        <Message Text="copy capture tool complate to '$(OutputPath)tools\capture'"
            Importance="high" />
    </Target>

create a classlibrary project using netframework 4.7 named A
create a winform project using netframework 4.7 named B
in Project B make a project reference to A
in Project A make a PackageReference to the package

when rebuild Project B
only project A output has the message

Verbose Logs

No response

@Y-Theta
Copy link
Author

Y-Theta commented Nov 9, 2022

output like this

已启动重新生成…
1>------ 已启动全部重新生成: 项目: ClassLibrary1, 配置: Debug Any CPU ------
已还原 D:\Program\MyProj\C#\Cli\WindowsFormsApp1\WindowsFormsApp1.csproj (用时 8 ms)。
已还原 D:\Program\MyProj\C#\Cli\ClassLibrary1\ClassLibrary1.csproj (用时 39 ms)。
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2203,5): warning MSB3270: 所生成项目的处理器架构“MSIL”与引用“C:\Users\mc_yangjieming.nuget\packages\mctech.lib.growingio\1.0.0\lib\net47\manualtrackCliDll.dll”的处理器架构“AMD64”不匹配。这种不匹配可能会导致运行时失败。请考虑通过配置管理器更改您的项目的目标处理器架构,以使您的项目与引用间的处理器架构保持一致,或者为引用关联一个与您的项目的目标处理器架构相符的处理器架构。
1> ClassLibrary1 -> D:\Program\MyProj\C#\Cli\ClassLibrary1\bin\Debug\ClassLibrary1.dll
1> copy ssssss
1> copy capture tool complate to 'bin\Debug\tools\capture'
2>------ 已启动全部重新生成: 项目: WindowsFormsApp2, 配置: Debug Any CPU ------
2> WindowsFormsApp2 -> D:\Program\MyProj\C#\Cli\WindowsFormsApp2\bin\Debug\WindowsFormsApp2.exe
========== 全部重新生成: 成功 2 个,失败 0 个,跳过 0 个 ==========

@donnie-msft donnie-msft added the WaitingForCustomer Applied when a NuGet triage person needs more info from the OP label Nov 9, 2022
@donnie-msft
Copy link
Contributor

Hello,
I found a similar report against MSBuild here: dotnet/msbuild#5797
Take a look at that thread and see if it looks similar to you.

MSBuild also made some changes recently. The default was changed with VS 2022 (17.0) (dotnet/msbuild#6622). It looks you're using VS 2019, so the default is still set to false with your setup.

It is now possible to opt into reasonable behavior: set the property MSBuildCopyContentTransitively to true in a Directory.Build.props file (or in individual projects--but you probably want this for your whole repo).
(see more details at dotnet/msbuild#1054 (comment))

Please take a look and let us know if you're able to resolve your issue.

@Y-Theta
Copy link
Author

Y-Theta commented Nov 10, 2022

but my vs2022 has the same action ;
is that because I'm not using the sdk-style project

@ghost ghost added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Nov 10, 2022
@Y-Theta
Copy link
Author

Y-Theta commented Nov 10, 2022

NuGet Product Used

NuGet.exe

Product Version

nuget.exe 6.3.0.131

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

create a package with struct like mctech.lib.desktopcapture -1.4.2 -buildTransitive -net47 -McTech.Lib.DesktopCapture.targets

and in the targets have a

   <Target Name="T2"
        AfterTargets="Build">
        <Message Text="copy capture tool complate to '$(OutputPath)tools\capture'"
            Importance="high" />
    </Target>

create a classlibrary project using netframework 4.7 named A create a winform project using netframework 4.7 named B in Project B make a project reference to A in Project A make a PackageReference to the package

when rebuild Project B only project A output has the message

Verbose Logs

No response

When I change Porject A and Project B to sdk-style project it works

@zivkan
Copy link
Member

zivkan commented Nov 10, 2022

@Y-Theta Please see https://learn.microsoft.com/nuget/consume-packages/package-references-in-project-files#using-packagereference-for-a-project-with-no-package-dependencies

SDK styles default to PackageReference, as they don't support packages.config. But as the docs say, for non-SDK style projects, a project either needs a PackageReference, or to define the RestoreProjectStyle.

@donnie-msft donnie-msft added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. labels Nov 10, 2022
@ghost ghost added the Status:No recent activity No recent activity. label Nov 29, 2022
@ghost
Copy link

ghost commented Nov 29, 2022

This issue has been automatically marked as stale because we have not received a response in 14 days. It will be closed if no further activity occurs within another 14 days of this comment.

@ghost ghost closed this as completed Dec 14, 2022
@ghost ghost added Resolution:NeedMoreInfo This issue appears to not have enough info to take action and removed Status:No recent activity No recent activity. labels Dec 14, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Resolution:NeedMoreInfo This issue appears to not have enough info to take action Type:Bug WaitingForCustomer Applied when a NuGet triage person needs more info from the OP
Projects
None yet
Development

No branches or pull requests

4 participants