Visual Studio 2017 MSBuild Task Development

烈酒焚心 提交于 2019-12-05 15:23:14

Is there a way to automatically copy all dependencies to the Debug folder? Or do I have to publish it every time I want to test it?

By default and for good reasons, .NET Core and .NET Standard projects do not copy referenced assemblies into the build folder. Instead, they are resolved them from the NuGet cache.

But if you really need it, this behavior can be changed by overriding the default with the CopyLocalLockFileAssemblies setting.

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

Cref: https://github.com/dotnet/sdk/blob/d20405f91a2959fa91fea6285d9a896286727f2a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.BeforeCommon.targets#L55-L56

Second question

It seems that as soon as I change the TargetFramework from netstandard1.4 to netstandard1.6

To build a task assembly that works on both "MSBuild.exe" and "dotnet.exe msbuild", you should target netstandard1.4 or lower. netstandard1.6 is not compatible with .NET Framework 4.6.1 (which MSBuild.exe runs on.)

If you need API not available in netstandard1.4, you will need to cross-compile your task for .NET Framework and .NET Standard, which is considerably more complex but can be done.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!