Skip to content

Library to work with MSBuild solution and project files

License

Notifications You must be signed in to change notification settings

isotes/vs-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vs-utils License Build Status Javadoc Maven Central

Library to work with MSBuild solution and project files based on the Java model generated from the official XML Schema files.

Overview

The scope of this project is rather limited and its existence stems mostly from problems of using the official .net API provided by Microsoft. The package has been used as a building block for migrating and normalizing VC++ projects and performing temporary changes in the context of Continuous Integration workloads. It has not been tested with any other project types. No MSBuild installation is required.

The model is generated with XMLBeans based on the official XML Schema files provided for MSBuild project files.

One the one hand, this projects adds support for reading and writing solution files. On the other hand, it contains helper classes to simplify working with project files, especially VC++ *.vcxproj files, and to work around idiosyncrasies of the upstream model and applications. For example, the write routine tries to make sure files are as close to the ones written by Visual Studio as possible, even if the upstream handling of empty tags is inconsistent. Furthermore, based on the upstream schema, most elements may occur multiple times even if semantically only one is possible, e.g., for specifying the compiler warning level. MSBuild seems to use the last occurrence while evaluating the project. Moreover, most simple elements that seem to be strings are simply specified as xs:any. The utility class X contains methods to make working with these elements more convenient.

Use

See Maven Central for the current Maven coordinates. This library requires Java 8 but should also work with newer versions and has a single dependency on the vs-model package.

The following introductory example shows how to modify project files. More information is in the API documentation.

VsSolution solution = new VsSolution(solutionPath));
for (VsSolutionProject vsp : solution.projects) {
    ProjectWrapper project = new ProjectWrapper(vsp.path);
    for (ProjectConfiguration projectConfiguration : project.configurations()) {
        ConfigurationWrapper cfg = projectConfiguration.resolve();
        cfg.propertyGroup.put("PlatformToolset", "v142");
        X.set(cfg.clCompile.getMultiProcessorCompilationList(), "true");
        if (X.string(cfg.clCompile.getWarningLevelList()).orElse("").equals("Level4")) {
            X.set(cfg.clCompile.getDisableSpecificWarningsList(), "4710;4711");
        }
    }
    project.save(project.path);
}

License

Apache 2.0

Note: For the unit tests, the Gradle build downloads the MIT licensed 'Hilo' solution and project files from the VCSamples repository.

About

Library to work with MSBuild solution and project files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages