Code Monkey home page Code Monkey logo

readonlysourcetree's Introduction

Read only source tree

Build status NuGet package

This project contains a NuGet package that will cause any project it is installed into to build its primary output and intermediate files to bin and obj directories at the root of your repository instead of as subdirectories to the project directory.

This makes structuring your repository after this pattern much easier:

RepoRoot\
    README.md
    LICENSE
    src\
        solution.sln
        project1\
        project2\
    bin\
        debug\
            project1\
            project2\
    obj\
        debug\
            project1\
            project2\
    packages\
        binary_dependency1\
        binary_dependency2\

This isolation of source files from build outputs can be useful for many reasons, including:

  1. Delete all build outputs for your entire repository just by deleting the top level bin and obj folders.
  2. Zip up your src directory and only get source -- no binaries.

Additional steps

Identifying the root of your repository

Heuristics are used by default to determine where the root of your repository is. You can see the heuristics in this MSBuild file's definition of the MSBuild RepoRoot property. It looks for files that are commonly found in the root of the repo. If the heuristics don't fit your repository, you can create an empty .RepoSrcRoot file in the top-level src folder of your repository.

Consolidate all NuGet packages

By default NuGet will expand packages to a directory beneath your solution directory. To get it to install packages to a sibling of your src directory instead, create a nuget.config file in the root of your repository with this content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositorypath" value="packages" />
  </config>
</configuration>

readonlysourcetree's People

Contributors

aarnott avatar

Stargazers

dzmitry-lahoda avatar Dominic Hopton avatar Giorgi Chakhidze avatar Yuri Gettya avatar Jan Karger ツ ☀ avatar Thomas Freudenberg avatar Damian Reeves avatar

Watchers

James Cloos avatar  avatar

Forkers

cammouren bubdm

readonlysourcetree's Issues

Build folder and Intermediate build folder are created and used inside the project folder

Steps to repro:
-Zip the current repo
-Extract the "DefaultCSharpClassLibrary" folder
-Open it Under VS14.0.24720.0 CE using File->Open-Project/Solution
-Save a solution file under the parent folder ".."
-Modify MSBuild project build output verbosity in VS to diagnostic
-Restore the "ReadOnlySourceTree" Nuget package updating it to the current latest (1.13)
-Clean the solution
-Build the solution
-Copy and paste MSBuild output to a log file (attached in for my system here... sorry but in french because I have not found a way to output it in english)
MSBuildLog.txt

IntermediateOutputPath needs to be set before .targets

The ReadOnlySourceTree.targets may not be imported before other NuGet packages that need to read such properties as IntermediateOutputPath. This causes build failures in consuming projects because other .targets will read the properties during evaluation model and try to write to files in directories that do not exist.

DocumentationFile is not redirected properly to the binaries location

Nuget package: ReadOnlySourceTree.0.1.37-beta
A csproj uses this Nuget package and has this property:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    ...
    <DocumentationFile>bin\Debug\Foo.xml</DocumentationFile>
    ...
  </PropertyGroup>

Build fails with this error:

CSC : error CS0016: Could not write to output file '.....\bin\Debug\Foo.xml' -- 'Could not find a part of the path

It looks like the build doesn't set the DocumentationFile property to point to the same folder at the binary.

The workaround is to have this property. The condition is for ensuring that the documentation file is not generated when the project is being built by GenerateTemporaryTargetAssembly, when ReadOnlySourceTree is not imported.

<DocumentationFile Condition="'$(OutputPath)' != ''">$(OutputPath)$(AssemblyName).xml</DocumentationFile>

Support for native projects

(first: this is a great project--thanks!)

I tried adding the ReadOnlySourceTree NuGet package to a solution that contained a native DLL project. It correctly got rid of the bin/obj directories from under the native DLL's project source directory, but instead of the resulting native DLLs going into \bin, they just went at the root (\x64\Debug and \x64\Release for x64 binaries; \Debug and \Release for x86 binaries.

Suppress XML doc file generation under project folder

Because the C#/VB project systems tend to write out the explicit project-relative output path for the XML file, it needs to be explicitly rewritten in the readonlysourcetree.targets to prevent its generation under src. It is already copied to the proper bin folder. We just need to keep it out of the wrong folder in the first place.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.