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

msbuild /t:Pack seems to copy assemblies from project references instead of output folder. #227

Open
softlion opened this issue May 22, 2020 · 1 comment

Comments

@softlion
Copy link

Hey again ! 😀

I have a msbuild Target which calls the obfuscar tool on the assemblies output of a build (in AfterBuild). I can't get it to work fully when packing a SDK Extra project.

When using /t:Pack, the nuget package contains an obfuscated assembly only for the SDK extra project, and a non obfuscated assembly for the library project that the SDK project is referencing.

The most strange thing is that all assemblies in each output folder of the SDK Extra project are correctly obfuscated.

It seems that the packing process ignores the output folder for referenced projects. I know that referenced projects are normally ignored by the packing target, which adds a nuget dependency instead (each project should have its nuget). I used this "trick" to get it into the main package instead:

  <PropertyGroup>
 <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
  </PropertyGroup>
  <Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
    <ItemGroup>
      <BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
    </ItemGroup>
    <Message Text="BuildOutputInPackage: @(BuildOutputInPackage)" />
  </Target>

An excerp of the obfuscar target:

<Target Name="Obfuscate" AfterTargets="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
    <ItemGroup>
       <AssembliesToObfuscate Include="$(TargetDir)\*.dll" />
    </ItemGroup>
     ...
    <Copy DestinationFolder="$(TargetDir)" SourceFiles="@(ObfuscarFiles)" />
  </Target>
@softlion
Copy link
Author

softlion commented May 22, 2020

Ok i found the .nuspec file that the packing process is generating. It uses the output path of the referenced project for its assembly instead of the output path of the SDK Extra project (which contains the same assembly but obfuscated).

The problem is that i can't obfuscate the output of the referenced project alone. All assemblies need to be obfuscated at the same time.

Do you know an extension point where i can fix the content of this nuspec file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant