Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet pack doesn't include xmlserializer assembly #6890

Open
livarcocc opened this issue May 1, 2018 · 7 comments
Open

dotnet pack doesn't include xmlserializer assembly #6890

livarcocc opened this issue May 1, 2018 · 7 comments
Labels
Functionality:Pack Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:dotnet.exe Status:Excluded from icebox cleanup Status:Inactive Icebox issues not updated for a specific long time Type:DCR Design Change Request
Milestone

Comments

@livarcocc
Copy link

From @Styxxy on May 1, 2018 13:10

When forcing assembly to generate XmlSerializer assembly,when packing the project, this XmlSerializer assembly is not included in the nupkg.

Project file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net47</TargetFramework>
    <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
    <SGenUseProxyTypes>false</SGenUseProxyTypes>
  </PropertyGroup>

</Project>

command dotnet pack myproject.csproj generates following nuspec (in the obj folder):

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
  <metadata>
    <id>myproject</id>
    <version>1.0.0</version>
    <authors>myproject</authors>
    <owners>myproject</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package Description</description>
    <dependencies>
      <group targetFramework=".NETFramework4.7" />
    </dependencies>
  </metadata>
  <files>
    <file src="c:\users\styxxy\Source\Repos\myproject\myproject\bin\Debug\net47\myproject.dll" target="lib\net47\myproject.dll" />
  </files>
</package>

I would expect the XmlSerializer assembly to be included as well.

Copied from original issue: dotnet/sdk#2202

@livarcocc
Copy link
Author

@rohit21agrawal can you take a first look here and let us know if the SDK is missing passing something down to pack?

@livarcocc
Copy link
Author

From @Styxxy on May 1, 2018 17:40

I created for now nuspec files, though it isn't ideal. Sample nuspec:

<package>
  <metadata>
    <!-- include all of necessary tags -->
    <references>
      <reference file="myproject.dll" />
    </references>
  </metadata>
  <files>
    <file src="bin\$config$\net47\myproject.dll" target="lib\net47" />
    <file src="bin\$config$\net47\myproject.XmlSerializers.dll" target="lib\net47" />
  </files>
</package>

(Typed on my phone.)

Initially I found a workaround by adding a custom target before the _GetProjectFiles target and adding the XmlSerializers assembly, but I encountered the problem when installing the package in a legacy project, that the XmlSerializers asembly is also added as a reference (default nuget adds all DLL's in the package as a reference, except *.resources.dll files).

@livarcocc
Copy link
Author

From @Styxxy on May 1, 2018 17:50

Doesn't matter whether using ("old") way or new way (using nuget package).

<!-- "old" way -->
  <PropertyGroup>
    <GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
    <SGenUseProxyTypes>false</SGenUseProxyTypes>
</PropertyGroup>

<!-- "new" way (see: https://docs.microsoft.com/en-us/dotnet/core/additional-tools/xml-serializer-generator ) -->
<ItemGroup>
  <PackageReference Include="Microsoft.XmlSerializer.Generator" Version="1.0.0" />
  <DotNetCliToolReference Include="Microsoft.XmlSerializer.Generator" Version="1.0.0" />
</ItemGroup>

@livarcocc
Copy link
Author

From @rohit21agrawal on May 1, 2018 18:15

This is currently not supported, we will consider this feature ask for a future release.
@Styxxy you don't need to revert to a nuspec. You can use these extension points/targets to add the serializer assembly to your package:
https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#targetsfortfmspecificbuildoutput

@livarcocc please feel free to move this issue to nuget.

@livarcocc
Copy link
Author

From @Styxxy on May 1, 2018 18:39

@rohit21agrawal
That does partially the trick. When installing into a project that uses packages.config, the XmlSerializer assembly is still referenced though (not that it breaks anything, it isn't nice though).

xmlser

<PropertyGroup>
  <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);GetMyPackageFiles</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<Target Name="GetMyPackageFiles">
  <ItemGroup>
    <BuildOutputInPackage Include="$(OutputPath)$(AssemblyName).XmlSerializers.dll" />
  </ItemGroup>
</Target>

@livarcocc
Copy link
Author

From @rohit21agrawal on May 1, 2018 18:43

@Styxxy that's correct, the issue is being tracked here: #6858
But i hope the workaround is better than having to manually manage a nuspec.

@rohit21agrawal
Copy link
Contributor

@Styxxy have you considered using contentFiles for XmlSerializer assemblies, instead of adding them to the lib folder of the package?

@ghost ghost added the Status:Inactive Icebox issues not updated for a specific long time label Sep 1, 2022
@jeffkl jeffkl added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. and removed Pipeline:Icebox labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Pack Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:dotnet.exe Status:Excluded from icebox cleanup Status:Inactive Icebox issues not updated for a specific long time Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

6 participants