modelsbuilder / ModelsBuilder.Original

The Community Models Builder for Umbraco
MIT License
114 stars 49 forks source link

How do we install the VS Extension and nuget package? #8

Closed djomen closed 10 years ago

djomen commented 10 years ago

Is there a an extension installer?

I have downloaded the project to build it myself but when i open the project in Visual Studio i get the following error for the Custom Tool project:

Zbu.ModelsBuilder.CustomTool\Zbu.ModelsBuilder.CustomTool.csproj: The application which this project type is based on was not found. Please try this link for further information:

http://msdn.microsoft.com/en-US/vstudio/ff718165

That link doesnt really help.

So im now stuck on the Extension.

Secondly - in the wiki notes for the custom tool it says:

Requires that the Site Integration package is installed, either via NuGet or as an Umbraco package

But ive searched Nuget for this package and come up with nothing.

What is the command for the package manager console to install the said package.

So im stuck on both counts! Apologies if im being thick and missed something completely obvious - but for my 1st project using the factory i hand crafted the models. Now i am starting another and thought id give this a whirl now i understand it all.

I have also watched the uHangout vid but again you didnt show where to actually download/get the package or extension - just what you saw once inside VS.

Be handy to update the docs when you have this info.

zpqrtbnk commented 10 years ago

The binaries are, at the moment and because we're in a beta phase, not released on the NuGet servers, etc. The only place where you can find them all is on the release page, ie 2.0.0-beta9 as I'm writing this.

So you probably do not want to build the binaries by yourself.

Should you still want to rebuild... because we're building a Visual Studio Extensions you need to install the proper Visual Studio SDK. Have updated the Building & Versionning doc accordingly.

djomen commented 10 years ago

DOH! I didn't see the releases tab. Sorry! Going to go hang my head in shame now.

djomen commented 10 years ago

Ok i got the package and the extension installed but the package didn't add any items to my web.confg.

So i have added the following items that need:

<add key="Zbu.ModelsBuilder.EnableApi" value="true"/>
<add key="Zbu.ModelsBuilder.ModelsNamespace" value="UmbracoBase.Web.Models.DocumentTypes"/>

And i have added a builder class and set the custom tool and set the properties in the zbu options.

When i save the class i now get the following error:

Warning 22 Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. UmbracoBase.Web

Where is the build log and have i missing something?

zpqrtbnk commented 10 years ago

If you want to use the Visual Studio extension... you do not need to enable the API as it is enabled by default, and you do not need to indicate a namespace in web.config as the Visual Studio extension is going to override it anyway. So it's normal that there's nothing in web.config.

Good that you are testing all this, will help me improve the doc.

Regarding the warning that you get... this is strange. It happens when you save the file... so probably when the extension triggers. Can you hit View | Output in Visual studio and find the extension's output (you have to pick the right "Show output from..." & I can't remember which one it is in). Can you copy/paste the whole thing here?

djomen commented 10 years ago

1st issue was id put the wrong login name (damn having to use an email because i cant get used to not using admin!) :) i got this error:

ZbuModelsBuilder: Starting 7/20/2014 1:02:41 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Response status code does not indicate success (Unauthorized)

ZbuModelsBuilder: at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result) at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.ValidateClientVersion() at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

So i changed the username and now im getting this:

ZbuModelsBuilder: Starting 7/20/2014 1:03:48 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=0.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","ExceptionType":"System.IO.FileLoadException","StackTrace":" at Zbu.ModelsBuilder.Building.CodeParser.Parse(IDictionary2 files)\r\n at Zbu.ModelsBuilder.AspNet.ModelsBuilderApiController.GetModels(GetModelsData data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"} ZbuModelsBuilder: at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result) at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.GetModels(Dictionary`2 ourFiles, String modelsNamespace) at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

Be good to add to docs to view Output window for errors because i didnt know where to look.

zpqrtbnk commented 10 years ago

Yes, I'm waiting 'till we sort out your issues and then will update the doc accordingly.

As for the missing assembly error... my mistake. Beta-9 is broken, I forgot to update a dependency in the NuGet package. Stupid, stupid me. Uploading beta-10 asap, stay tuned. Sorry, really....

djomen commented 10 years ago

Hey no problem - happy to help to get this working with you.

djomen commented 10 years ago

Just me know how to upgrade the package as i seem to remember reading you cant do an update - so how to remove and re-add as im a little unfamiliar outside nuget.

zpqrtbnk commented 10 years ago

You can now get new files from beta10. I think that you do not need to update the Visual Studio extension, so just try to keep it unchanged. As for the package... are you using the Umbraco package? Best to uninstall and re-install then.

djomen commented 10 years ago

no im using the nuget package but added manually

zpqrtbnk commented 10 years ago

Mmm... dunno how you're supposed to update a manually installed (from file) nuget package. Either Google for it or uninstall/reinstall I guess.

djomen commented 10 years ago

I uninstalled the packages and added v10

but im still getting an error:

ZbuModelsBuilder: Starting 7/20/2014 1:23:37 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=0.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","ExceptionType":"System.IO.FileLoadException","StackTrace":" at Zbu.ModelsBuilder.Building.CodeParser.Parse(IDictionary2 files)\r\n at Zbu.ModelsBuilder.AspNet.ModelsBuilderApiController.GetModels(GetModelsData data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>c__DisplayClass5.<ExecuteAsync>b__4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"} ZbuModelsBuilder: at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result) at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.GetModels(Dictionary2 ourFiles, String modelsNamespace) at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg) ZbuModelsBuilder: Starting 7/20/2014 1:23:59 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=0.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","ExceptionType":"System.IO.FileLoadException","StackTrace":" at Zbu.ModelsBuilder.Building.CodeParser.Parse(IDictionary2 files)\r\n at Zbu.ModelsBuilder.AspNet.ModelsBuilderApiController.GetModels(GetModelsData data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass13.bc(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>cDisplayClass5.b4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"} ZbuModelsBuilder: at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result) at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.GetModels(Dictionary2 ourFiles, String modelsNamespace) at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg) ZbuModelsBuilder: Starting 7/20/2014 1:25:11 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'System.Collections.Immutable, Version=1.1.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","ExceptionType":"System.IO.FileLoadException","StackTrace":" at Zbu.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary2 files, SyntaxTree[]& trees)\r\n at Zbu.ModelsBuilder.Building.CodeParser.Parse(IDictionary2 files)\r\n at Zbu.ModelsBuilder.AspNet.ModelsBuilderApiController.GetModels(GetModelsData data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass13.bc(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>cDisplayClass5.b4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"} ZbuModelsBuilder: at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result) at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.GetModels(Dictionary2 ourFiles, String modelsNamespace) at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

djomen commented 10 years ago

I have uninstalled the extension also and added v10 extension. Now i get a different error:

ZbuModelsBuilder: Starting 7/20/2014 1:31:05 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'System.Collections.Immutable, Version=1.1.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)","ExceptionType":"System.IO.FileLoadException","StackTrace":" at Zbu.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary2 files, SyntaxTree[]& trees)\r\n at Zbu.ModelsBuilder.Building.CodeParser.Parse(IDictionary2 files)\r\n at Zbu.ModelsBuilder.AspNet.ModelsBuilderApiController.GetModels(GetModelsData data)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>cDisplayClass13.bc(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.<>cDisplayClass5.b4()\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)"} ZbuModelsBuilder: at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result) at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.GetModels(Dictionary2 ourFiles, String modelsNamespace) at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

zpqrtbnk commented 10 years ago

Damn. See, I have updated the Roslyn dependency to use their latest version, and obviously something's wrong.

Can you right-click on you project in VS, "Manage NuGet Packages", and tell me which packages exactly are installed (with version)? There should be Zbu.ModelsBuilder, which depends on Microsoft.CodeAnalysis.CSharp, which depends on Microsoft.CodeAnalysis.Common, which depends on Microsoft.Bcl.Immutable which therefore should be there too!

djomen commented 10 years ago

on its way

zpqrtbnk commented 10 years ago

Got your email. Now I see what the issue is. Microsoft.CodeAnalysis.Common wants Microsoft.Bcl.Immutable >= 1.1.20... so if there's nothing yet it installs 1.1.20... but on my dev machine I updated both Roslyn and Microsoft.Bcl.Immutable so now I have 1.1.22, so when I build Zbu.ModelsBuilder it wants that one.

So I guess... there's going to be a beta-11 ;-(

That being said, you should be able to fix it right now on your side: go to Manage NuGet Package then go to Updates and there should be updates for Microsoft Immutable Collections and maybe also *Microsoft ECMA-335 Metadata Reader". Do update both, and then all should be fine.

NuGet updates sure are fun ;-((

djomen commented 10 years ago

Ill get the update from you because that package is pointing to the old libs so will need updating also.

zpqrtbnk commented 10 years ago

OK, can you try beta11? What a mess -- really sorry about it.

djomen commented 10 years ago

ZbuModelsBuilder: Starting 7/20/2014 2:38:02 PM. ZbuModelsBuilder: ZbuModelsBuilder failed to generate code: Exception: Panic: no projets. ZbuModelsBuilder: at Zbu.ModelsBuilder.CustomTool.VisualStudio.VisualStudioHelper.GetSourceItem(String inputFilePath) at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

djomen commented 10 years ago

Is this a config issue?

zpqrtbnk commented 10 years ago

Exit and restart Visual Studio. That one is an internal VS error, don't know what to do about it.

djomen commented 10 years ago

Ah i just did a rebuild on the project and voila! :)

Nice one... Thanks Stephan.

I'll go check it all out now.

zpqrtbnk commented 10 years ago

WOOT!

hfloyd commented 10 years ago

I have a similar issue...

I installed the VS extension using the vsix file, not nuget, and used the umbraco package to install ModelBuilder to the umbraco website (via the Dev section int he back-end). Perhaps this wasn't wise?

Anyway, initially, the CustomTool in VS worked fine, but subsequently, if I attempt to run it (either by editing and saving the file, or by right-clicking and choosing "Run Custom Tool"), I get this error:

{"Message":"An error has occurred.","ExceptionMessage":"Could not load file or assembly 'Microsoft.CodeAnalysis, Version=0.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.","ExceptionType":"System.IO.FileNotFoundException","StackTrace":"   at Zbu.ModelsBuilder.Building.CodeParser.Parse(IDictionary`2 files)\r\n   at Zbu.ModelsBuilder.AspNet.ModelsBuilderApiController.GetModels(GetModelsData data)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}
ZbuModelsBuilder:    at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.EnsureSuccess(HttpResponseMessage result)
   at Zbu.ModelsBuilder.AspNet.ModelsBuilderApi.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
   at Zbu.ModelsBuilder.CustomTool.CustomTool.ZbuModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)

If I uninstall and re-install the VS extension, it will work again, but then stops functioning again later. I assume that something is getting lost somewhere in between system reboots or whatever...

The Package Manager for the project lists no installed packages, and nothing comes up if I do a search for "Microsoft.CodeAnalysis.CSharp", so I can't seem to just add the dependencies.

zpqrtbnk commented 10 years ago

@hfloyd Installing the VS extension using the VSIX file, and the Umbraco component using the Umbraco package, makes perfect sense.

The error that you see is not linked to the VS extension (so no need to uninstall and re-install) but to some DLLs installed by the Umbraco package. There were some issues with some packages that I released so make sure you are using the latest version.

After you install the Umbraco package, can you check the ~/bin directory of your Umbraco install and ensure that a file named Microsoft.CodeAnalysis.dll is present in there? Then, when you get the error, can you check again that the file is present?

hfloyd commented 10 years ago

Thanks, Stephan for your reply. The version I am using is 2.0.0-beta14 from the releases tab. The files were missing from my website project, though I'm not sure why they disappeared (or why re-installing the VSIX fixed it initially... very peculiar) When I re-added them to the bin, it ran without error. Thanks for pointing me in the right direction. :+1: