简体   繁体   中英

Custom Nuget Package files not deploying extra files with web publish

We have a nuget package we developed and use internally. One package has addtional unmanaged DLL's that need to be deployed. In VS2015, I right-click on the web application project and publish to a test server. None of the unmanaged DLL's in the package were published, but they are in the bin folder on my machine.

Here's what I'm trying in the package targets file:

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="ExtraFilesPublishTarget">
    <Message Text="########### NUGET DEPLOY ###########"/>
    <ItemGroup>   
    <DistFiles Include="$(MSBuildThisFileDirectory)..\lib\dist\**\*.*"/>
    <FilesForPackagingFromProject Include="%(DistFiles.Identity)">
      <DestinationRelativePath>\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
    </FilesForPackagingFromProject>
    </ItemGroup>
  </Target> 
  <Target Name="DistBuildTarget" AfterTargets="Build">
    <ItemGroup>
      <DistFiles Include="$(MSBuildThisFileDirectory)..\lib\dist\**\*.*"/>
    </ItemGroup>
    <Microsoft.Build.Tasks.Copy SourceFiles="@(DistFiles)" DestinationFiles="@(DistFiles->'$(OutputPath)\%(RecursiveDir)%(Filename)%(Extension)')" />
  </Target>
  <PropertyGroup>
    <copyallfilestosinglefolderforpackagedependson>
      ExtraFilesPublishTarget;
      $(copyallfilestosinglefolderforpackagedependson);
    </copyallfilestosinglefolderforpackagedependson>
    <copyallfilestosinglefolderformsdeploydependson>
      ExtraFilesPublishTarget;
      $(copyallfilestosinglefolderforpackagedependson);
    </copyallfilestosinglefolderformsdeploydependson>
  </PropertyGroup>
</Project>

When I publish, I see the NUGET DEPLOY message, but the next line in the output window is "Target "ExtraFilesPublishTarget" skipped. Previously built successfully."

The link above ( http://blog.mjjames.co.uk/2012/10/deploying-non-project-files-with-web.html ) solved my problems.

I did have another issue with targets not found. To save time in testing, I would edit my .targets file in the packages folder for my solution. If you add or rename a target in the local .targets file, VS2015 won't find the change since it caches the target names. You have to close down VS or reinstall the package to it to be found. You can change the elements within the target, you just can't change the name of the target or add a target.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM