Hi @Aditya Dalai ,
Unfortunately, there isn't a direct way to automatically update these file paths when you update your NuGet package version, as NuGet doesn't support running custom scripts during package installation in .NET Core and .NET Standard projects because of security reasons.
However, you could try below ways:
1)Instead of hardcoding the version number in your .csproj
file, you could use an MSBuild property. This allows you to define the version in one place and use that property throughout your project file.
<PropertyGroup>
<SipSiVersion>4.0.10</SipSiVersion>
</PropertyGroup>
<PackageReference Include="sip-si" Version="$(SipSiVersion)" />
<Target Name="CopyReferenceDll" AfterTargets="Build">
<Copy SourceFiles="..\..\_Common\packages\sip-si.$(SipSiVersion)\lib\netstandard2.0\Wrapper.dll" DestinationFolder="$(TargetDir)" />
</Target>
2)For the DLL and PDB files, you can use wildcard versioning in the file path if your package versions follow a consistent naming convention.
<Copy SourceFiles="..\..\_Common\packages\sip-si.*\lib\netstandard2.0\Wrapper.dll" DestinationFolder="$(TargetDir)" />
3)If you have control over the NuGet package (sip-si
), you can include a .targets
file within the package that contains the necessary MSBuild logic to copy the files and reference them correctly using the property.
4)Although NuGet doesn't allow running PowerShell scripts during package installation anymore, you could use a custom MSBuild target that runs after package restoration to update the references.
Best regards,
Jalpa Panchal
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.