我有一个自定义 nuget 包,其中包含 \build
文件夹中的 .targets
文件。当我将其安装到.net框架项目中时,安装后,我们可以在项目文件中看到以下导入列表:
<Import Project="..\packages\xxxx\build\xxxx.targets" Condition="Exists('..\packages\xxxx\build\xxxx.targets')" />
但是当我将其安装到 .net core 项目时,我无法在项目文件中找到此导入列表,如果 .net core 支持的话,我可以在其中找到我的 .targets
文件?
最佳答案
Where is the .targets file, and if it supported by .net core
.targets
文件包含在obj文件夹下的project.assets.json
文件中,您可以查看project.assets.json
code> 文件,则可以得到如下代码:
"xxxx/1.0.0.0": {
"type": "package",
"build": {
"build/xxxx.targets": {}
}
},
并且这个.targets
文件也受到.net core项目的支持。作为测试,我在 nuget 包中创建了一个测试 .targets
文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Test" AfterTargets="Build">
<Message Text="This is Test Sample!"></Message>
</Target>
</Project>
将此 nuget 包安装到 .net core 项目后,然后构建该项目,我可以获得带有消息“This is Test Sample!
”的输出窗口
关于visual-studio-2017 - .targets 文件在哪里,.net core 是否支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50869803/