I'm working on a VS solution with 100+ projects in C#. I'm currently migrating it from VS 2008 to VS 2010. There is some work to be done because a lot of the projects use Enterprise Library 4 (which has to be upgraded to 5.0) and WCSF 2008 (which has to be upgraded to SCSF 2010). I'm going through the SCSF upgrade instructions, and one involves doing this:
Add a reference to the following
Service Location assembly in each
project that has a reference to an
Enterprise Library assembly.
Microsoft.Practices.ServiceLocation.dll
Is there any way to do this without going through the IDE? I mean, opening up each of 100-odd projects, then checking the references, then adding a reference if necessary, is one way of doing it, but is there a faster way? I was thinking along the lines of doing a search over the project files for a particular reference, then doing an insert if it was found.
If you've done this kind of thing before, suggestions would be very welcome. Thanks.
If you want to do this through the IDE, you can write a macro using VSProject.References to add/remove references as necessary.
However, C# project files (.csproj) are just XML, so you may be able to write a simple utility that can adjust the file as necessary using the standard XML classes.
Related
i need to port a VS2005 Project (.NET2) to a VS2008 (.NET3.5) (or to VS2010 .NET4 not yet defined).
The project is composed by:
resources and configuration files (VS project files, like: .settings
.vbproj .myapp .config .xconfig .Designer.vb);
a lot of VB codes;
xsc, xsd, xss and xsx files;
a lot of Crystal reports for VS2005;
graphical resources.
The application take data in order to generate reports from more DB SQL Server 2005 istances.
What is the best way to approach to a migration activity?
Is there an internal migration tool?
If yes, what's the best practice to use it?
Which kind of files will be automatically ported to the new VS version?
Thanks in advance for all the provided information
It should be backward compatible.
Therefore, you should be able to simply open the project in the target version of Visual Studio and perform a conversion if required (for the project files). I suggest taking a backup first however, just in case.
Then compile test and test some more.
Should be fine.
We had to separate a class library from core library project. And now, we should add the reference of the new project to the other 50 or something projects in a solution, which is ASP.NET MVC solution if it matters. Is there any way to automate this addition of reference? I have resharper but I can't find such a functionality with it.
VSCommands 2010 enables you to copy and paste references (as well as several other very useful features). Not quite automated, but much less painful than having to open each project's references and navigating to add ref.
Another way would be to do some sort of search and replace in csproj files using NotePad++ or some other text editor.
You can also take a look at the Powershell console (I think its part of Nuget) and modify your proj files with powershell commands. Take a look here (deals with manipulating references): how to find reference path via *.csproject file
Here's a puzzler - something that doesn't work that I assumed would (no surprise there).
We have a library project that is referenced in a few other desktop app projects. The library project is written in VS 2005 (.NET 2.0).
My problem is that some of our apps still live in VS 2005 for the time being (for various reason). I can't seem to reference this library project in VS 2010 without it demanding that I upgrade it to .NET 4, which if I do, then breaks my ability to include it as a reference in my VS 2005 projects.
This type of thing fries my brain. Is there any way I can make this work?
Hmm, that doesn't make a lot of sense. You don't reference a 'library project', you reference the DLL that it produces. Project + Add Reference, Browse tab. There's no known problem with that, within a 95% accuracy guess, mixed mode assemblies have a few hairs.
If you actually try to load a vs2005 project into a vs2010 solution, then yes, it's going to try to convert the project file. And that turns vs2005 catatonic, it doesn't have the time machine to guess what a vs2010 project looks like. Just making a copy of the project directory solves that problem.
Can you change the .NET version back to 3.5 or 2.0 in VS.NET 2010 after it revises the project version to .NET 4.0?
Use a file reference to the built dll, rather than a project reference.
You may also find you need to add an extra bit of compatible-framework info to your manifest file to tell .net to allow your .exe to use .net 4 and .net 2 assemblies alongside each other - if it's not there you'll just get an error on startup. (Sorry, I can't remember the exact details and I'm not at my work machine right now to be able to find them - but if you have problems at runtime, the error message should lead you to the exact solution you need)
Correction: I was thinking of this 'useLegacy' startup setting, which you may need to add to your app.config if you want to use a mixture of .net 2.0 and .net 4.0 assemblies in your application:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
On option, that is a complete PITA, but should work is:
Create a new project file in 2010 that includes everything the 2005 project file has. Just call it MyProject2010.csproj or whatever.
Then, add this project to your 2010 solution.
I'm in the process of upgrading our VS 2008 solution to run on VS 2010
I managed to successfully build in VS 2010
My next step now is to configure a build machine running TFS 2008
Whenever I start a build it does my projects in alphabetical order with no regard for dependencies. I've googled a lot and I can't seem to find a solution to this.
The closest solution to my problem is found here: msdn link which links to this: dependency solution
However I'm dealing with 129 projects, so I would really rather not do this all manually in the xml.
Has anyone been able to effectively remap the dependencies in a way which msbuild recognizes without manipulating the xml for days...?
It turns out that the conversion to VS 2010 makes the build agent have to use the .NET 4.0 version of msbuild.
So I followed the steps outlined here and it worked: Building .NET 4.0 Applications Using Team Build 2008. Keep in mind that those instructions were written during the beta and the path is now v4.0.30319.
This was required even though all my projects are targeting 3.5
Basically I had to make a one line change and now everything is happy (still working on getting my build to pass but the order is good). It had nothing to do with dependencies not being preserved, simply that the way dependencies were being managed wasn't understood by msbuild 3.5
We also have a large number of projects. We wound up (programmatically) creating a MasterSolution.sln file that contained all of the projects. We also require our developers to only use project references in their code. This way, MSBuild always gets the correct order as it parses the .sln file.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Change the Target Framework for all my projects in a Visual Studio Solution
I have a just converted a Visual Studio project from 2005 to 2008 to take advantage of the .NET 3.5 Framework features. My solution contains approximately 80 projects and I want to set the Target Framework to .NET Framework 3.5 for all of them. Is there a way I can do this without manually going in and changing them one-by-one in Properties -> Application -> Target Framework?
You would need to edit all the .csproj files and change the line:
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
You could write a program that would scan your projects folders for all .csproj files, read them as text (or perhaps xml), update that line and then write them out again.
You might have an issue though if they're not already VS 2008 projects. So convert them first. And as you're doing that it'll probably be just as quick (if not quicker) to update the target framework version by hand.
Having said that, why not leave it alone until you make code changes the project anyway. As your code works now, and the only reason you want to update is to make use of the new features you're going to have to edit the project anyway.
In theory you could do a diff between the .csproj files before and after changing the framework version. .csproj is an XML file, so it's something you could write a program to parse and change.
In practice, I'd not do this, as there may be subtleties that this may miss. For instance: do installation projects work the same way? Web deployment projects?
Also, suppose it takes you a couple of seconds to do each one by hand. This will take about two or three minutes to do the whole solution. That may actually be faster than writing the code ... !