Call exe in nuget package while accessing mscorlib.xml

robert's Avatar

robert

29 Jul, 2018 05:18 AM

The System.IO.Abstractions is a C# repository that uses the <inheritdoc /> tag to link to System.IO documentation. Unfortunately to make this documentation available in the System.IO.Abstraction nuget package the xml documentation files needs to be modified at the before_package stage in the appveyor deployment.

The inheritdoc nuget package provides an exe tool that does this modification, but I'm unsure where to find or how to access this tool as part of the appveyor deployment. On my local machine this exe is found for .NET standard/core here:

\Users\<your user name>\.nuget\packages\inheritdoc\1.2.0.1\tools\InheritDoc.exe

but it also takes in a set of parameters that are paths to other files, such as the project directory to search for the xml files to change, and the paths to the System.IO xml documentation files.

How would I run this exe from the appveyor.xml if it looks like this on my local machine:

\Users\<user name>\.nuget\packages\inheritdoc\1.2.0.1\tools\InheritDoc.exe -b '\path\to\project\directory\' -g 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X\mscorlib.xml' -o

  1. Support Staff 1 Posted by Owen McDonnell on 29 Jul, 2018 06:26 AM

    Owen McDonnell's Avatar

    From what i can see, provided the inheritdoc package is installed, the only modifications needed in that command is path\to\project\directory, which you should be able to swap out with %APPVEYOR_BUILD_FOLDER% environment variable, and <user name> in first parameter should be appveyor.

    Give it a try and let us know if any troubleshooting is needed.

  2. 2 Posted by robert on 29 Jul, 2018 08:07 PM

    robert's Avatar

    I added this line the the appveyor.yml:

    before_package:
    # This step replaces the inheritdoc tags in the xml documentation with documentation from mscorlib.xml
    - ps: \Users\appveyor\.nuget\packages\inheritdoc\1.2.0.1\tools\InheritDoc.exe -b '%APPVEYOR_BUILD_FOLDER%' -g '\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X\mscorlib.xml' -o
    

    but it produced the following error:

    \Users\appveyor\.nuget\packages\inheritdoc\1.2.0.1\tools\InheritDoc.exe -b '%APPVEYOR_BUILD_FOLDER%' -g '\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X\mscorlib.xml' -o
    2018-07-29 02:52:45.5775|INFO|InheritDoc.Program|InheritDoc(v1.2.0.1).Run():basePath=%APPVEYOR_BUILD_FOLDER%,xmlDocFileNamePatterns=,overwriteExisting =True
    \Users\appveyor\.nuget\packages\inheritdoc\1.2.0.1\tools\InheritDoc.exe : 
    At line:1 char:1
    + \Users\appveyor\.nuget\packages\inheritdoc\1.2.0.1\tools\InheritDoc.e ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
     
    Unhandled Exception:
     
    System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\projects\system-io-abstractions\%APPVEYOR_BUILD_FOLDER%'.
    

    I believe the C:\projects\system-io-abstractions\ is the clone/build directory, but unsure why the environment variable has been appended.

  3. Support Staff 3 Posted by Owen McDonnell on 30 Jul, 2018 04:17 AM

    Owen McDonnell's Avatar

    Can you please share your yaml file or go to Export Yaml tab if you are using UI for configuration.

  4. 4 Posted by robert on 30 Jul, 2018 05:57 AM

    robert's Avatar
  5. Support Staff 5 Posted by Owen McDonnell on 31 Jul, 2018 03:55 AM

    Owen McDonnell's Avatar

    %APPVEYOR_BUILD_FOLDER% is cmd syntax. For powershell, use $env:APPVEYOR_BUILD_FOLDER

  6. 6 Posted by robert on 31 Jul, 2018 08:48 AM

    robert's Avatar

    Thanks for the syntax correction, I changed the yml file to use the powershell syntax style with this environment variable but it kept the $env:APPVEYOR_BUILD_FOLDER rather than switching it for the path of the build directory. Does it require something else to tell it that its an environment variable?

    The build log can be found here: ci.appveyor.com

  7. Support Staff 7 Posted by Ilya Finkelshte... on 31 Jul, 2018 12:14 PM

    Ilya Finkelshteyn's Avatar

    In PowerShell variables are not being resolved if they wrapped on single quotas ('). So InheritDoc.exe is fed with literally -b $env:APPVEYOR_BUILD_FOLDER.

    You do not need to wrap $env:APPVEYOR_BUILD_FOLDER in quotas at all, but if you wish, use double quotas (").

    Also nuget package is being created as part of build stage. So if you need this command to be executed before, run it as before_build.

  8. 8 Posted by robert on 03 Aug, 2018 10:59 AM

    robert's Avatar

    Thanks, that got it working, except the script call only worked in before_package. However, it has been recommended that the InheritDoc nuget package only be used temporarily as part of the appveyor script and neither installed nor deployed with System.IO.Abstractions.
    Is it possible to temporarily install a nuget package? Maybe using the Powershell Install-Package cmdlet? Does appveyor already have the nuget packageprovider installed, and does the InheritDoc nuget package need to be uninstalled after the fact (using Uninstall-Package)?

  9. Support Staff 9 Posted by Owen McDonnell on 03 Aug, 2018 04:22 PM

    Owen McDonnell's Avatar

    Sure, using nuget cli will avoid adding any reference of the package to your project.
    So something like - ps: nuget install InheritDoc -Version 1.2.0.1 should work.

    No need to uninstall since build VM's are transient and destroyed after the build anyway.

  10. 10 Posted by robert on 13 Aug, 2018 06:46 AM

    robert's Avatar

    Hopefully this is the final part of getting this change in place. I'm trying to put the duplicated components into environment variables:

    environment:
      INHERITDOC_VERSION: "1.2.2.1"
      TEMP_DIR: c:/temp
    
    I managed to get it working for the nuget call:
    install:
    - nuget install inheritdoc -Version %INHERITDOC_VERSION% -OutputDirectory %TEMP_DIR%
    
    but I've had no luck running the following call:
    before_package:
    - ps: $env:TEMP_DIR\InheritDoc.$env:INHERITDOC_VERSION\tools\InheritDoc.exe -b $env:APPVEYOR_BUILD_FOLDER -g 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.X\mscorlib.xml' -o
    
    I get the following error:
    At line:1 char:14
    + ... env:TEMP_DIR\InheritDoc.$env:INHERITDOC_VERSION\tools\InheritDoc.exe  ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Unexpected token '\InheritDoc.$env:INHERITDOC_VERSION\tools\InheritDoc.exe' in expression or statement.
    
    How do I go about fixing this?
    If it helps, the full yaml file can be found here, and the log file here.
  11. Support Staff 11 Posted by Owen McDonnell on 13 Aug, 2018 03:31 PM

    Owen McDonnell's Avatar

    Try putting the call operator (&) in front of the problematic line. Like so,

    before_package:
    - ps: & $env:TEMP_DIR\InheritDoc.$env:INHERITDOC_VERSION\tools\InheritDoc.exe -b $env:APPVEYOR_BUILD_FOLDER -g 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.X\mscorlib.xml' -o
    
  12. Support Staff 12 Posted by Owen McDonnell on 13 Aug, 2018 05:04 PM

    Owen McDonnell's Avatar

    Sorry, you should also wrap the whole command in single quotes.

    before_package:
    - ps: '& $env:TEMP_DIR\InheritDoc.$env:INHERITDOC_VERSION\tools\InheritDoc.exe -b $env:APPVEYOR_BUILD_FOLDER -g 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.X\mscorlib.xml' -o'
    

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac