我需要在我的.NET Framework控制台应用程序的.csproj文件中使用
它嵌套在
当代码写成这样时,编辑器会给我这个错误:
<attrib>
[文档]元素。它嵌套在
<Target Name="BeforeBuild">
元素中,因为我需要在构建之前编辑一些文件的属性。以下是.csproj的完整代码:<Target Name="BeforeBuild">
<Attrib Files="App.config" ReadOnly="false" />
<Attrib Files="Ocelot.json" ReadOnly="false" />
<Attrib Files="OcelotLogging.json" ReadOnly="false" />
</Target>
当代码写成这样时,编辑器会给我这个错误:
任务'Attrib'未定义
。
我尝试了什么?
我会使用<UsingTask>
元素,其中参数是NAnt.Core NuGet包的路径。整个代码如下:
<UsingTask TaskName="Attrib" AssemblyFile="C:\Users\UserName\.nuget\packages\nant.core\0.92.0\lib\net40\NAnt.Core.dll" />
<Target Name="BeforeBuild">
<Attrib Files="App.config" ReadOnly="false" />
<Attrib Files="Ocelot.json" ReadOnly="false" />
<Attrib Files="OcelotLogging.json" ReadOnly="false" />
</Target>
但错误并没有消失。当我尝试编译应用程序时,我得到以下错误:The "Attrib" task could not be loaded from the assembly C:\Users\UserName\.nuget\packages\nant.core\0.92.0\lib\net40\NAnt.Core.dll. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.