npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vs-parse

v3.1.2

Published

A parser for Visual Studio solutions and projects

Downloads

1,767

Readme

vs-parse

Azure Pipelines Build Status

Node-based parser of Visual Studio projects/solutions.

Modules

All functions come in synchronous and asynchronous versions. Synchronous versions are suffixed with "Sync". Asynchronous versions return a promise which resolves to the same value as the synchronous version of a function.

parseSolution

parseSolutionSync

Solution file parser

const parseSolution = (file, options = {}) => Promise.resolve({})
const parseSolutionSync = (file, options = {}) => {}

Examples

From a path

const parser = require('vs-parse');
const solutionData = await parser.parseSolution('HelloWorld.sln');

From a string

const parser = require('vs-parse');
const fs = require('fs');

const contents = fs.readFileSync('HelloWorld.sln', { encoding: 'utf-8' });
const solutionData = await parser.parseSolution(contents);

From a buffer

const parser = require('vs-parse');
const fs = require('fs');

const buffer = fs.readFileSync('HelloWorld.sln');
const solutionData = await parser.parseSolution(buffer);

Sample Output

const parser = require('vs-parse');
const solutionData = await parser.parseSolution('HelloWorld.sln');

console.log(solutionData);
/*
  Outputs:

  {
    fileFormatVersion: '12.00',
    visualStudioVersion: '15.0.27004.2009',
    minimumVisualStudioVersion: '10.0.40219.1',
    projects: [
      {
        id: '1580E0CD-6DAA-4328-92F6-2E0B0F0AB7AF',
        name: 'TestNUnit3',
        relativePath: 'TestNUnit3\\TestNUnit3.csproj',
        projectTypeId: 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC'
      }
    ]
  }
*/

A full parse of a solution and all its dependencies can be done by passing the deepParse option. This will force the parser to enumerate and parse all dependent projects (as well as their dependencies). See parseProject() for details.

Example:

const parser = require('vs-parse');
const solutionData = await parser.parseSolution('HelloWorld.sln' { deepParse: true });

console.log(solutionData);
/*
  Outputs:

  {
    fileFormatVersion: '12.00',
    visualStudioVersion: '15.0.27004.2009',
    minimumVisualStudioVersion: '10.0.40219.1',
    projects: [
      {
        id: '1580E0CD-6DAA-4328-92F6-2E0B0F0AB7AF',
        name: 'TestNUnit3',
        relativePath: 'TestNUnit3\\TestNUnit3.csproj',
        projectTypeId: 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC',
        codeFiles: [
          {
            fileName: 'MyFile.cs'
          }
        ],
        packages: [
          {
            name: 'NUnit',
            version: '3.7.1',
            targetFramework: 'net452'  
          }
        ],
        references: [
          {
            assemblyName: 'nunit.framework',
            culture: 'neutral',
            hintPath: '..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll',
            processorArchitecture: 'MSIL',
            publicKeyToken: 'b035f5f7f11d50a3a',
            version: '3.7.1.0'
          }
        ]
      }
    ]
  }
*/

parseProject

parseProjectSync

Parses a project file.

const parseProject = (file, options = {}) => Promise.resolve({})
const parseProjectSync = (file, options = {}) => {}

Examples

From a path

const parser = require('vs-parse');
const projectData = await parser.parseProject('./TestNUnit3/TestNUnit3.csproj');

From a string

const parser = require('vs-parse');
const fs = require('fs');

const contents = fs.readFileSync('./TestNUnit3/TestNUnit3.csproj', { encoding: 'utf-8' });
const projectData = await parser.parseProject(contents);

From a buffer

const parser = require('vs-parse');
const fs = require('fs');

const buffer = fs.readFileSync('./TestNUnit3/TestNUnit3.csproj');
const projectData = await parser.parseProject(buffer);

Sample Output

Example:

const parser = require('vs-parse');
const projectData = await parser.parseProject('./TestNUnit3/TestNUnit3.csproj');

console.log(projectData);
/*
  Outputs:

  {
    codeFiles: [
      {
        fileName: 'Class1.cs'
      }
    ],
    references: [
      {
        assemblyName: 'nunit.framework',
        culture: 'neutral',
        hintPath: '..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll',
        processorArchitecture: 'MSIL',
        publicKeyToken: 'b035f5f7f11d50a3a',
        version: '3.7.1.0'
      }
    ]
  }
*/

A full parse of a project and all its dependencies can be done by passing the deepParse option. This will force the parser to enumerate and parse all packages. Project files using the <PackageReference> format do not require this option to return dependent packages. Dependency parsing will defer to the dependencies listed in packages.config over <PackageReference> if a packages.config file is present.

Example:

const parser = require('vs-parse');
const projectData = await parser.parseProject('./TestNUnit3/TestNUnit3.csproj', { deepParse: true });

console.log(projectData);
/*
  Outputs:

  {
    codeFiles: [
      {
        fileName: 'Class1.cs'
      }
    ],
    packages: [
      {
        name: 'NUnit',
        version: '3.7.1',
        targetFramework: 'net452'  
      }
    ],
    references: [
      {
        assemblyName: 'nunit.framework',
        culture: 'neutral',
        hintPath: '..\packages\NUnit.3.7.1\lib\net45\nunit.framework.dll',
        processorArchitecture: 'MSIL',
        publicKeyToken: 'b035f5f7f11d50a3a',
        version: '3.7.1.0'
      }
    ]
  }
*/

parsePackages

parsePackagesSync

Parses a nuget 'packages.config' file.

const parsePackages = (file, options = {}) => Promise.resolve({})
const parsePackagesSync = (file, options = {}) => {}

Examples

const parser = require('vs-parse');
const packages = await parser.parsePackages('./packages.config');

console.log(packages);
/*
  Outputs:

  [
    {
      name: 'NUnit',
      version: '3.7.1',
      targetFramework: 'net452'  
    }
  ]
*/

parseSemverSync

A very simple semver parser. Mostly a wrapper over standardized tools, with support for .NET-specific assembly versioning.

const parser = require('vs-parse');

const versionString = '1.2.3.4';
const versionInfo = parser.parseSemverSync(versionString);

console.log(versionInfo);
/*
 Outputs:

 {
    major: '1',
    minor: '2',
    patch: '3',
    version: '1.2.3',
    originalString: '1.2.3.4'
  }
*/

Module Parser Options

An options object can be passed to a parsing function to customize its behaviour.

Deep Parse

deepParse - Specifying true will also read and parse all dependencies. Defaults to false.

Example: A solution is dependent on its projects, while a project is dependent on its packages.

Directory Root

dirRoot - The root directory under which the solution or project lives. Defaults to undefined.

Required when doing a deep parse of a solution or project from file contents or a buffer.