I have a solution that has 4 projects in it. 3 are dependencies for my tests and the other is just my tests.
DL
BI
MySite (web site)
MyTests
Some unit tests in the MyTests project reference namespaces in the web site MySite for some MVC contollers.
Question is how do I get just the MyTests project to build and deploy with a TFS build. NO matter what I try the _publishedWebSites folder on the TFS build machine always has the web site and not the MyTests folder. For some reason it thinks it is building the web site and not the tests. Any help would be appreciated from the build definition or solution perspective.
The purpose is to build the tests and distribute them to a server where they can be run (selectively) using the command line tool in the task manager. I cannot distribute them if I cannot get the solution to build properly.
Alright so there are a few things. Firstly, you need to make sure that the outer solution recognizes MyTests as the start up project and has the other projects as build dependencies. However, this likely won't solve your problems. In order to do this you'll probably have to create a custom build script or edit your solution/project files by hand. The problem with the latter approach is that if other people are building MySite from this solution editing the project file to exclude it's output from the drop is going to cause problems for them.
My personal approach would be to make an MSBuild script which specifies the order in which to build the projects and which files you want in the drop. It's fairly straight forward and it will probably be easy to specify the output you want (this is sometimes very tedious if the projects build is messy to begin with or it has excessive and convoluted dependencies).
Here's the outer most resource for MSBuild. I'd look it over and think about what the simplest solution is but I wouldn't be surprised if you can just make every project build using their project files then add a single build step to cleanse your output.
Related
When trying to run NUnit tests with ReSharper, the following message appears in a dialog box and the tests are not run:
The build could not be started. There are multiple projects in the solution at... <name of the csproj file>
I have this problem with Resharper 8.2.1
I have several projects in my solution. Most of the projects are class libraries. One of the projects is a Web Site (not project exactly). Another one is a Web Application. The Web Site and the Web Application projects are located in the same directory. The Web Site is set to be built only in the Release build.
I have this problem only in The Web Application project, when I try to run some embedded tests in this project. I do not have this problem in other (class library) projects.
The problem was in JetBrains' bug tracker, but was closed: https://youtrack.jetbrains.com/issue/RSRP-328627
Perhaps there some workaround?
Update:
When I "Project -> Unload Project" on the Web Site, the problem disappears
I had the same problem (also with 8.2), at least the same error when running my tests through the menu Resharper > Unit Tests > Run All Tests from Solution. But I found the following work around :
Right click on your unit testing project and select Run Unit Tests. this will start running all the tests from the project (from the resharper interface)
Alternatively you can set up you unit testing solution as start up project and from the Resharper menu choose > Unit Tests > Run Unit Tests
Of course you have to do it for each project that has unit tests, but I guess this is acceptable.
Remark: it seems to be a known bug of version 8.2 https://youtrack.jetbrains.com/issue/RSRP-411631
And that rolling back to 8.1 can fix the problem
Hope this helps.
In my case this happened after running performance analysis (i.e. profiling) in Visual Studio.
As documented here, the solution was to remove these lines from the .sln file:
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection}
Check whether you have any changes to your solution file. I encountered this problem after a source control branch change, when Visual Studio held on to a bunch of changes from the previous branch. Not sure exactly what the cause was, but reverting the changes to my sln file fixed the issue.
I have many projects that I want to build using TFS Build. I have no problems with Windows Forms and WebForms PROJECTS.
But when I try to use TFS Build to build ASP.NET Website (the classic one), I have these problems:
I don't have any options to compile the project with Test Configuration (only Debug or Release).
I can't build an ASP.NET website because it's not a Web Project.
I want to know if there's a way to publish the website's precompiled files to the same shared location where I have my other projects.
I think I might need a bit more detail here, or maybe I'm just clueless :-)
Test configuration - I'm assuming you've set up a Test build configuration? If so, I'm not sure off the top of my head what's going on, but I've seen people forget to create the build configuration.
We've had no problem with our Websites, they get moved to build output or to wherever you specify in the Website properties pages
If you mean you want to use WebDeploy to publish, you're out of luck for the website - only web projects will do that. But do a little team build customization, and you should be able to emulate that.
Not super satisfied with my answer, but hopefully I've pointed you towards something helpful...
So I have a solution which contains 4 projects, a "Core" Project which is the actual application (as a class library), and 3 wrapper projects, "Console", "WinForm" and "Service" which basically wraps a Facade class in the core class and contains various settings to handle different logging strategies for each different application (Console/Trace/File) and launch the application as either a Console, WinForms or Service, depending on how the customer wishes to deploy the application.
In the Core project I have 3 resource files which contain simple template views for the Nancy web framework. However the way Nancy looks for these views are on the current path. Since the files in the Core project aren't on the current path for any of the 3 other projects I need a simple way to access these files across projects.
Somewhat naively I thought this was where the concept of a "Solution" came in, to handle dependencies between projects. However by searching the Internet, much to my surprise, it appears there is no elegant way to do this. The only two solutions I've been able to find involves copying the files to a scratch/temporary or directory in the solution, and copying them to the respective needed directories later, as post build actions, and Adding an item manually using "Add as Link". Now while both these solutions technically work, the first leaves (possibly out-of-date) build artefacts lying about where they don't really belong (IMHO), and the second is tedious, time-consuming and prone to human error (because you can't just link to a directory).
Are these really my only two options, or is there some third, totally obvious way I've just missed because I'm new to Visual Studio?
You could use a custom IRootPathProvider in Nancy, if the only things you need are Nancy specific.
The other option is to link a folder - you can do this, but it involves manually hacking on the csproj file, there's a few questions on here about it, including this one:
Visual Studio Linked Files Directory Structure
Nuget is a package management system, that I have used to share artifacts between projects as dependencies. You could include libraries available via nuget.org or have your own nuget packages defined.
Teamcity has got good support for generating nuget packages with every build and can serve as a Nuget server.
Here is a reference to include files into a nuget package.
We have around ~ 80 C# projects in a single Git repository.
Our CI server is TeamCity, and we use it to build upon every commit to our git master repository.
I am trying to come up with the best way to build all of the projects on the server.
These projects are currently grouped together in a few .sln files (around 20 projects each), is it a common practice to create a "master" solution file with ALL projects such that the build server will only need to build this solution?
Or is it preferable to keep some MSBuild or other script file that will itself execute the building of each solution/project whatever it sees fit?
We are also using TeamCity with about 130 projects all in the one solution. There is not fits all answer. For CI I believe the critical issue is how long it takes to build and run tests. Both on your build farm and on developer boxes. Do the simplest possible thing for efficient software development.
Mind you the tricky thing is what is fast? Speed is relative and different developers can work very different. Some like to only commit once a day for example. So it needs to be context.
Have your TeamCity build build the same as you do on your developer boxes. Less layers the better. Keep it simple.
See similar answer: Visual Studio Large Solution.
I have a C#/ASP.NET website that has some code (*.cs) files in the App_Code directory. I would like to test them using NUnit. I have written a test file with the proper [TestFixture] and [Test] annotations and have put it here: App_Code/Test/TestClassName.cs.
I load up the NUnit GUI to run it but it wants me to select a .exe or .dll file. There is none in the bin folder of my project. My project does successfully run and is built and everything, but still no exe or dll file. How can I get the NUnit Gui to just run the test in that class?
I don't recommend putting test code in the same package you'll be deploying to production.
You may want to move the test classes to a library project, something like Business.UnitTest(there may be a built in way to create an nUnit specific project, if there is, use that). Then move the business classes that are in your App_Code directory into another project called Business. Have Business.UnitTest reference the Business library. That should get nUnit to run(I don't believe that nUnit runs against websites, only libraries, but I'm not 100% sure).
For your website add a reference to the business library you just created so your production code can access the business objects in the business library. You may have to work out some namespace issues, but that shouldn't be too bad.
The trick with .NET Website projects is that the code files are not normally compiled up front, they are compiled on execution of the respective pages. This presents a challenge where testing is concerned, since as you mentioned NUnit wants to run a .exe or .dll for testing.
One way to deal with the issue is to convert the website project to a web application; they sound similar, but work in different ways. In contrast to a website not requiring up-front compilation, a web application requires it. So you would have one or more projects that compile to assemblies (.dll) or executables (.exe). NUnit could then hook into those to run the tests.
To make this work, you would want to separate testable code into another project; your front-end web application can refer to this other project to make use of the code within. Ideally, the front-end would be a thin layer of logic and user interaction, and the real work can be sent to the second project. Therefore, the second project is what you will want to test.
You'll want to have one more project to contain the tests - general wisdom is to not have your tests in the same project as the code being tested. This project refers to the project being tested, and to NUnit, and contains the tests themselves. This assembly is what you would direct NUnit to run for testing.
First, you want to create a new project for your tests. If you happen to have any internal classes or attributes, you should use InternalsVisibleToAttribute in order to be able to test these from within your testing project, outside your "real" project.
This attribute is suitable for the entire assembly, so I recommend putting it into your Assembly.info file of your "real" assembly.
From within your tests project, add a reference to your "real" assembly.
Make sure to exactly know the path to your binary (assembly.dll);
Open your TestsProjectAssembly.dll from within your NUnit GUI, makeing sure you are browsing to the right folder;
You might also want NUnit GUI to reload your assembly on each tests run (there is an option for doing so in the options properties);
Run your tests.
Absolutely make sure your path or browsable folder is the one in which your testing project is generated.