Multi-framework NuGet build with symbols for internal dependency management

后端 未结 3 1043
执笔经年
执笔经年 2021-01-31 10:47

Maybe I\'m pushing the envelope here, but I\'m desperate to leverage NuGet to ease the DLL Hell that I\'ve found myself in.

We have 4 main products that all live in inte

3条回答
  •  天涯浪人
    2021-01-31 11:20

    Xavier's answer led me in the proper direction, and also informed my Google searching. I was not fully aware of the file declarations, and when searching along those lines, I found Joshua Flanagan's post Tips for building NuGet packages, which is excellent. Xavier and Joshua together taught me a few things:

    1. You don't have to assemble a conventions-conforming file tree in order to build a package. It's much better to use the file element to select files and target them to a destination directory within the assembled NuGet package.
    2. NuGet's -Symbols flag doesn't just work for packaging on a .csproj file. When you do use it on a .csproj file, then sure, that's how it figures out how to package up all your source files. But you can also use -Symbols on a .nuspec file that includes the source via file elements. The normal NuGet package will not include the src directory, but the Symbols package will.

    So now, let me describe my build process as it occurs on my CI server:

    1. Build the solution using the "3.5 Release" solution configuration.
    2. Build the solution using the "4.0 Release" solution configuration.
    3. Use ILMerge.exe to internalize some assemblies. I have these output to (for example) bin\Release-3.5\merged so I don't have to monkey with renaming the target assembly to temp.dll before I use it in the merge.
    4. Build the package against the .nuspec in Powershell.

    Here is the package command:

    nuget pack src\MyProject\MyProject.nuspec -OutputDirectory .\output -Build -Symbols -Version $Version
    

    Note that $Version is passed in from the build server so I can use its build number as the last part of the version.

    Here is the .nuspec file:

    
    
        
            MyProject
            0.0.0
            MyProject
            David Boike
            David Boike
            false
            MyProject
            
            Copyright 2012
            my tags
        
        
            
            
            
            
            
            
            
        
    
    

    Note that I have removed a lot of the more informative elements from my nuspec because it just doesn't matter for an internal project like this.

    The result is a package for my private NuGet server that contains DLL, PDB, and XML documentation for the assembly for both .NET 3.5 and 4.0, and then a separate symbols package for my private SymbolServer that includes all of the above plus the source. This is very easy to view with the NuGet Package Explorer which I highly recommend you download.

    Finally, I tested everything and with the Visual Studio setup suggested at symbolsource.org (except with my own private symbol server) I was able to debug the code and easily step into the source.

    Thanks again to Xavier for leading me down the right path!

提交回复
热议问题