0
votes

I'm creating a solution with 2 projects. A class library and a console application to have the XUnit project. Both applications target .net 451 and .net core frameworks.

For the library I have "netstandard1.3" "net451"

For the xunit project I have "netcoreapp1.0" "net451"

I'm having problems when debugging the unit tests inside Visual Studio 2015, using the test explorer, when I try to debug, the symbols are not loaded.

Is there any setup for the projects that I'm missing? Any limitation in Visual Studio 2015 ?

I had this project and tests working fine only targeting .net core version. The problem started after introducing the net451 target. Everything builds right and the tests also are discovered correctly.

Thanks in advance!

project.json from library project

"version": "1.0.4",   
"files": {
  "includeFiles": [
    "Content/ReleaseNotes.txt"
  ],
  "include": [
    "../../README"
  ]
},   
 "releaseNotes": "Review ReleaseNotes.txt for details.",
    "requireLicenseAcceptance": true
  },
 "buildOptions": {      
  },
  "frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.ComponentModel.DataAnnotations": "",
        "System.Data": "",
        "System.Drawing": "",
        "System.Drawing.Design": "",
        "System.Transactions": "",
        "System.Configuration": "",
        "System.Configuration.Install": "",
        "System.Management": "",
        "System.Xml": "",
        "System.Runtime": {
          "type": "build"
        }
      },
      "dependencies": {
        "Google.Protobuf": "3.0.0-beta4"
      }
    },
    "netstandard1.3": {    
      "buildOptions": {
        "define": [ "NETCORE10" ],
        "warningsAsErrors": false,            
        "embed": [
          "keywords.txt",
          "Resources.resx"          
        ],
        "resource": [ "**/*.resx" ],
        "compile": {
          "exclude": [
            "Framework/Net451/**/*.*",          
          ],
          "includeFiles": [
            "Resources.Designer.cs"            
          ],
          "excludeFiles": [
            "Properties/VersionInfo.cs",               
          ]
        }   
      },
      "dependencies": {
        "Microsoft.Extensions.Configuration.Json": "1.0.0",
        "NETStandard.Library": "1.6.0",
        "System.Collections.NonGeneric": "4.0.1",
        "System.ComponentModel": "4.0.1",
        "System.ComponentModel.Annotations": "4.1.0",
        "System.ComponentModel.Primitives": "4.1.0",
        "System.ComponentModel.TypeConverter": "4.1.0",
        "System.Data.Common": "4.1.0",
        "System.Data.SqlClient": "4.1.0",
        "System.Diagnostics.Process": "4.1.0",
        "System.Diagnostics.TextWriterTraceListener": "4.0.0",
        "System.IO.Compression": "4.1.0",
        "System.IO.FileSystem.Primitives": "4.0.1",
        "System.IO.MemoryMappedFiles": "4.0.0",
        "System.IO.Pipes": "4.0.0",
        "System.Linq.Expressions": "4.1.0",
        "System.Net.NameResolution": "4.0.0",
        "System.Net.Security": "4.0.0",
        "System.Net.Sockets": "4.1.0",
        "System.Reflection": "4.1.0",
        "System.Reflection.TypeExtensions": "4.1.0",
        "System.Security.Principal.Windows": "4.0.0",
        "System.Text.Encoding.CodePages": "4.0.1",
        "System.Threading.Timer": "4.0.1",
        "System.Threading.ThreadPool": "4.0.10",
        "Google.Protobuf": "3.0.0-beta4"
      }
    }
  }
}

project.json from xunit project

  {
  "version": "7.0.4",
  "description": "MyLibrary", 
  "packOptions": {  
    "requireLicenseAcceptance": true
  },
  "buildOptions": {   
  },
  "testRunner": "xunit",
  "dependencies": {
    "dotnet-test-xunit": "2.2.0-*",
    "xunit": "2.2.0-*",
    "MyLibrary": {
      "target": "project"
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dnxcore50"
      ],
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.0-*",
          "type": "platform"
        }
      },
      "buildOptions": {
        "define": [ "NETCORE10" ],
        "copyToOutput": [ "appsettings.json" ],
        "compile": {
          "include": [ "../*.cs" ],
          "exclude": [
            "**/._*",
            "Framework/Net451/**/*.*"
          ],
          "excludeFiles": [           
            "TestDataTable.cs"
          ]
        },
        "warningsAsErrors": false,
        "optimize": true      
      }
    },
    "net451": {
      "frameworkAssemblies": {
        "System.Collections": {
          "type": "build"
        },
        "System.Diagnostics.Debug": {
          "type": "build"
        },
        "System.Linq": {
          "type": "build"
        },
        "System.Reflection": {
          "type": "build"
        },
        "System.Reflection.Extensions": {
          "type": "build"
        },
        "System.Runtime": {
          "type": "build"
        },
        "System.Runtime.Extensions": {
          "type": "build"
        },
        "System.Threading.Tasks": {
          "type": "build"
        }
      },
      "buildOptions": {
        "compile": {
          "exclude": [
            "Framework/NetCore10/*.*"
          ],
          "excludeFiles": [
            "Framework/Net451/PerfMonTests.cs",
            "Framework/Net451/ReplicationTests.cs"
          ]
        }
      }
    }
  }
}
1

1 Answers

0
votes

Well, hope this save some time to someone else. I'm sort of new to the xproj projects and also still learning about all the options inside the new project.json file.Which I like so far. That said here's the answer to this particular issue.

I had an optimize = true outside the frameworks section which applies to all the configurations in the project. So the IDE was never generating the debug-able code. A good practice for this is having a configurations section in your project.json file where you define how you want the build to behave for each case. And here is the configurations section that I added.

"configurations": {
"Debug": {
  "buildOptions": {
    "define": [ "DEBUG" ],
    "optimize": false,
    "preserveCompilationContext": true
  }
},
"Release": {
  "buildOptions": {
    "define": [ "RELEASE" ],
    "optimize": true,
    "preserveCompilationContext": true,
    "xmlDoc": true
  }
}

And that's it.