Skip to content

Running executable from a NuGet package with PackageReference management format #5975

Closed

Description

I have a code base and two project files that target two versions of the .NET framework. Since I have them stored in the same folder I cannot rely on a Packages.config file since it will always incorporate one framework version and not the other. Thus I moved to PackageReference which worked great so far.

Unfortunately I just installed Mono.TextTemplating and wanted to execute the provided TextTransform.exe as a pre-build event on all of my *.tt files however I cannot reference it properly since it is stored under %userprofile%\.nuget\packages\mono.texttemplating\1.3.1\. The moment I update the package and forget about it, it will break since the new version will be stored under a different folder. Similiar to any changes of the local package storage.

How am I supposed to include executables from NuGet packages into my build steps now?

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): VS UI

NuGet version (x.x.x.xxx): 4.3

VS version (if appropriate): Enterprise 2017 (15.3.5)

OS version (i.e. win10 v1607 (14393.321)): Windows 10 v1703 (15063.608)

Activity

  1. added this to the Backlog milestone on Oct 2, 2017
  2. added
    Priority:2
    on Oct 2, 2017
  3. rrelyea commented on Oct 2, 2017

    @rrelyea
    Contributor

    Great scenario. @mishra14 is looking into similar issues with bootstrapping using PackageReference.

  4. rrelyea commented on Oct 2, 2017

    @rrelyea
    Contributor

    Great info. Thanks. I wasn't aware of that feature.
    Clearly we should improve the build side of this.

    Today, some tools set a msbuild property in their .props file, that consumers of that tool could use.

    You could imagine that we create msbuild props for every tools folder that you restore. $(PackageToolsDir_My_Package_Name) or the like...

  5. removed their assignment
    on Feb 15, 2018
  6. christianrondeau commented on May 16, 2018

    @christianrondeau

    We actually have the same requirement, and were greatly surprised to see there's no easy to find solution (and we searched pretty hard). Two scenarios:

    1. Running nunit3.console.exe requires either installing nunit, copying it in the git repo directly, or hardcoding the "expected" NuGet path from the user folder. All three prevents two projects referencing different versions of nunit which may not be compatible with the same nunit3.console.exe runner. (NOTE: Using dotnet test would be an alternative in that specific scenario)
    2. Running FluentMigrator's Migrate.exe. same thing

    A simple solution would be to have tools available in PackageReference/IncludeAssets. I guess it would be in ExcludeAssets by default, but we could then have the folder copied to the output folder and move on.

    Another solution could be to specify "additional files", which would be a simple mapping of files from the package and where we want them (e.g. globbing pattern). Dirtier, but I could then select the files I want in /tools rather than always copy everything.

    Finally, like @rrelyea said if we can get a variable to find the resolved package folder in a post-build event, we'd be good to go. Example of what that could look like:

    <PackageReference Include="MyPackage" Version="1.0.0" ExportPathVariable="MyPackageFolder" />
    <!-- ... -->
    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
      <Exec Command="copy $(MyPackageFolder)\tools\hello.exe $(OutDir)\" />
    </Target>
    
  7. added
    Resolution:Duplicate
    on Jun 14, 2018
  8. rrelyea commented on Jun 14, 2018

    @rrelyea
    Contributor

    Resolving dupe of this issue: #6949 which is in flight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority:2Resolution:DuplicateStyle:PackageReferenceType:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions