I had created a nuget package which includes .props and .targets in build folder.
Below is my .targets file:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UserTargetsPath>$(MSBuildProjectFullPath).user</UserTargetsPath>
</PropertyGroup>
<PropertyGroup>
<SDKInstallPath Condition=" '$(SDKInstallPath)' == ''">$(MSBuildThisFileDirectory)\..\lib\net46</SDKInstallPath>
<SetupPath>$(SDKInstallPath)\Sample.dll</SetupPath>
<SDKExtDir Condition=" '$(SDKExtDir)' == ''">$(SDKInstallPath)</SDKExtDir>
<MyExtension>$(SDKInstallPath)\Sample.dll</MyExtension>
</PropertyGroup>
<UsingTask TaskName="ResolveReferences" AssemblyFile="$(SDKInstallPath)"/>
<ItemGroup>
<MyExtension Include="$(MyExtension)" Condition=" '$(MyExtension)' != '' " ></MyExtension>
</ItemGroup>
<PropertyGroup>
<BuildDependsOn>
BeforeBuild;
CoreBuild;
AfterBuild
</BuildDependsOn>
</PropertyGroup>
<Target
Name="Build" DependsOnTargets="$(BuildDependsOn)"
/>
<Target Name="BeforeBuild" />
<Target Name="AfterBuild" />
<PropertyGroup>
<PrepareForBuildDependsOn></PrepareForBuildDependsOn>
</PropertyGroup>
<Target
Name="CoreBuild">
<CreateProperty Condition=" '$(MyExtensionSearchPaths)' == '' " Value="
$(ReferencePaths);
{HintPathFromItem};
{RawFileName};
$(SDKExtDir)
">
<Output TaskParameter="Value" PropertyName="MyExtensionSearchPaths" />
</CreateProperty>
<ResolveReferences
MyReferences="@(MyExtension)"
SearchPaths="$(MyExtensionSearchPaths)"
SearchFilenameExtensions=".dll">
<Output TaskParameter="ResolvedMyReferences" ItemName="_AllResolvedMyExtensionPaths" />
</ResolveReferences>
</Target>
</Project>
I have installed nuget package in c# project. Nuget package is installed successfully. But when i tried to compile my c# project, a build error is thrown see below:
"C:\MySample\MySample.csproj" (Build target) (1) ->
(CoreBuild target) ->
C:\MySample\packages\Sample.4.8.31\build\Sample.targets(69,5): error MSB4062:
The "ResolveReferences" task could not be loaded from the assembly C:\MySample\packages\Sample.4.8.31\build\..\lib\net46.
Could not load file or assembly 'file:///C:\MySample\packages\Sample.4.8.31\lib\net46'
or one of its dependencies. Access is denied. 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. [C:\MySample\MySample.csproj]
Build got failed In the below property
<ResolveReferences
MyReferences="@(MyExtension)"
SearchPaths="$(MyExtensionSearchPaths)"
SearchFilenameExtensions=".dll">
<Output TaskParameter="ResolvedMyReferences" ItemName="_AllResolvedMyExtensionPaths" />
</ResolveReferences>
Access is denied error is shown in the above error. Please suggest what had done wrong in the .targets file