Cannot build RazorGenerator tooling?

Jun 10, 2014 at 5:43 PM
I am having issues building the RazorGenerator tools solution. Everything builds fine except for the tooling project. The type or namespace name 'ProvideObject' could not be found. I am using Visual Studio 2010 and I am getting the following errors:

Error 2 The type or namespace name 'ProvideObject' could not be found (are you missing a using directive or an assembly reference?) C:\Users\KendallB\Documents\Git\razorgenerator\RazorGenerator.Tooling\RazorGenerator.cs 31 6 RazorGenerator.Tooling
Error 1 The type or namespace name 'ProvideObjectAttribute' could not be found (are you missing a using directive or an assembly reference?) C:\Users\KendallB\Documents\Git\razorgenerator\RazorGenerator.Tooling\RazorGenerator.cs 31 6 RazorGenerator.Tooling
Error 3 The type or namespace name 'ServiceProvider' could not be found (are you missing a using directive or an assembly reference?) C:\Users\KendallB\Documents\Git\razorgenerator\RazorGenerator.Tooling\BaseCodeGeneratorWithSite.cs 34 17 RazorGenerator.Tooling
Error 4 The type or namespace name 'ServiceProvider' could not be found (are you missing a using directive or an assembly reference?) C:\Users\KendallB\Documents\Git\razorgenerator\RazorGenerator.Tooling\BaseCodeGeneratorWithSite.cs 78 17 RazorGenerator.Tooling

Intellisense in the project shows the classes just fine, and I can F12 on them and it shows this:

region Assembly Microsoft.VisualStudio.Shell.10.0.dll, v11.0.0.0

// C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.VisualStudio.Shell.10.0\v4.0_11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Shell.10.0.dll

endregion

using System;

namespace Microsoft.VisualStudio.Shell
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
public sealed class ProvideObjectAttribute : RegistrationAttribute
{
    public ProvideObjectAttribute(Type objectType);

    public Type ObjectType { get; }
    public RegistrationMethod RegisterUsing { get; set; }

    public override void Register(RegistrationAttribute.RegistrationContext context);
    public override void Unregister(RegistrationAttribute.RegistrationContext context);
}
}

The assembly is referenced in the project correctly as far as I can tell, it just does not compile?

Also on a related note, if I wish to make my own changes to the tooling (or the MSBuild version), what is the process to debug the code? Is there a way to debug the process of transforming the files from within Visual Studio? Or is there some other mechanism you can use to trigger a transform outside of VS for testing purposes?
Coordinator
Jun 10, 2014 at 5:53 PM
Could you verify that you have the VS 2010 SDK SP1 (http://www.microsoft.com/en-us/download/details.aspx?id=21835) on your box? When I browse to the References node, Microsoft.VisualStudio.Shell.10.0 is listed as being referenced from C:\Program Files (x86)\Microsoft Visual Studio 2010 SDK SP1\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.Shell.10.0.dll.
  • For changes in the code generation, I use the samples in RazorGenerator.Core.Test to verify that the results match what I expect.
  • Testing the VSIX is relatively easy - make RazorGenerator.Tooling the start project and run F5. It should launch VS 2010 under an experimental profile and you should be able to break it into your code when you make changes to a file with the Custom Tool set to RazorGenerator.
  • For testing the MsBuild task, I put a System.Diagnostics.Debugger.Launch(); in the build task, and run msbuild on a project that uses the resulting binary.
Jun 16, 2014 at 2:14 AM
Edited Jun 16, 2014 at 2:22 AM
I am using Visual Studio 2012 right now, not 2010. Sorry about that! I went to install the VS2010 SP1 SDK and it will not install of course since I do not have VS2010 installed. Am I missing some other SDK for VS2012 that I need to be installing? I downloaded and installed the VS2012 SDK but it had no impact (I assume it was already installed along with VS2012 when I installed it).

Thanks for the feedback on debugging!
Coordinator
Jun 16, 2014 at 5:11 PM
I've a box with VS 2010 and later versions of VS installed SxS. I didn't research it enough, but it seemed like the only way to target a Vsix supporting 2010 was having the version installed locally. I think they sorted this issue out in VS 2012. If you're up for it, you could try tweaking the csproj file to make it work for your target environment. The NuGet vsix project - https://nuget.codeplex.com/SourceControl/latest#src/VsExtension/VsExtension.csproj - might give you some hints on how to go about it.
Coordinator
Jun 16, 2014 at 5:15 PM
I wonder if we should just stop supporting VS 2010 to reduce the headaches. I wouldn't think that too many people are still using it.
Jun 16, 2014 at 5:30 PM
I assume the VS2010 extension works in 2012 and 2013; if you built it with the 2012+ SDK, I assume then it would not work at all with VS2010? I have no idea how many people use 2010 these days; we switched off it ages ago. We plan to move to 2013 at some point in the near future, but just have not bothered yet (nothing new I need just yet in it :).
Aug 23, 2014 at 6:46 PM
Are there any updates on this? Is there a way to build the tooling without using VS2010, or do I need to install VS2010 in order to be able to build and debug the tooling?
Coordinator
Aug 25, 2014 at 3:10 AM
@KendallB, we really haven't spent any time trying to address this. Like I mentioned in my previous comment, you're welcome to try and change .csproj file to make it work without VS.
Coordinator
Aug 31, 2014 at 3:06 PM
Maybe we just need to remove support for 2010, and possibly even 2012. Presumably, if it only supported 2013, it would be easy to build with a straight 2013 install?
Coordinator
Sep 1, 2014 at 5:12 AM
I played with this a bit. To make it build in VS 2012, you just need to change the Target Framework of the RazorGenerator.Tooling project from .NET Framework 4.0 to 4.5. Can you give that a try?
Sep 1, 2014 at 4:58 PM
You are correct. I wish I knew it was that simple before! LOL. I never considered the project type, but changing it to 4.5 works for me.

I assume if it is changed to 4.5 it probably will no longer work with VS2010? So if there are going to be official builds for VS2010 and VS2012/13 it probably needs to be built for two different targets? Although the 2010 version works fine for 2012/2013.
Coordinator
Sep 2, 2014 at 3:51 AM
The trick was to look not just at the errors, but also the warning, which describe the framework mismatch fairly clearly. However, I noticed that after uninstalling VS2010 (&SDK) and making this change, even though it builds successfully, I'm not seeing any VSIX files being built. Do you see that too? Need to investigate further. Pranav may have ideas as he's more of an msbuild expert :)

Right, it would no longer work for 2010. The idea is to simply drop support for it. Most people have moved on from it, and we have limited time to work in this project, so I prefer to just simplify the scenario than trying to support everyone.