OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
79 stars 41 forks source link

Reference.tt is failing after updating to the VS2022 extension #319

Open vendettamit opened 1 year ago

vendettamit commented 1 year ago

After installing the connected services for VS2022 extension of connected service my Reference.tt stopped working. Getting error below:

I have this file on following locations but VS is not able to get the correction location. Any guidance would be really appreciated!!

Name                                 Location                                                                                             Modified              Size   Type                  Hits 

Microsoft.OData.ConnectedService.dll C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\benl3ycw.ecg\   10/4/2022 12:40:00 PM 116 KB Application extension 0    
Microsoft.OData.ConnectedService.dll C:\Users\achoudhary\AppData\Local\assembly\dl3\1D1ZWWOD.7JZ\GZ274JV9.266\6429e97b\13f5f2f1_0fd8d801\ 10/4/2022 12:53:52 PM 116 KB Application extension 0    
Microsoft.OData.ConnectedService.dll C:\Users\achoudhary\AppData\Local\assembly\dl3\1D1ZWWOD.7JZ\GZ274JV9.266\fe71e61f\6e8b3857_829cd801\ 9/20/2022 1:59:50 PM  319 KB Application extension 0    
Severity    Code    Description Project File    Line    Suppression State
Error       An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find file 'C:\dev\git\Source\Microsoft.OData.ConnectedService.dll'.
File name: 'C:\dev\git\Source\Microsoft.OData.ConnectedService.dll'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.StandardFileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.CommonCompilerFileSystemExtensions.OpenFileWithNormalizedException(ICommonCompilerFileSystem fileSystem, String filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)  CMECF.Client        1   

Note: Installing the latest extension v1.0.0 on VS2019 also not generating anything also no throwing any error.

ElizabethOkerio commented 1 year ago

@vendettamit this extension- [VS2022](https://marketplace.visualstudio.com/items?itemName=marketplace.ODataConnectedService2022) should be installed in visual studio 2022 and this extension - https://marketplace.visualstudio.com/items?itemName=marketplace.ODataConnectedService should be installed in visual studio 2019 or 2017.

Is it Reference.cs that is not working? or did you generate .tt files that you are working with?

jonantoine commented 1 year ago

I get the same issue when I added the tt files into the solution.

System.IO.FileNotFoundException: Could not find file 'D:\TestProjects\ConsoleApp1\Microsoft.OData.ConnectedService.dll'.
File name: 'D:\TestProjects\ConsoleApp1\Microsoft.OData.ConnectedService.dll'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.StandardFileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.CommonCompilerFileSystemExtensions.OpenFileWithNormalizedException(ICommonCompilerFileSystem fileSystem, String filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)  ConsoleApp1     1   
vendettamit commented 1 year ago

@vendettamit this extension- [VS2022](https://marketplace.visualstudio.com/items?itemName=marketplace.ODataConnectedService2022) should be installed in visual studio 2022 and this extension - https://marketplace.visualstudio.com/items?itemName=marketplace.ODataConnectedService should be installed in visual studio 2019 or 2017.

Is it Reference.cs that is not working? or did you generate .tt files that you are working with?

The .tt file was added in the VS 2019 extension then we moved to 2022 and that's when this issue started happening. So I had to switch back to 2019 to generate by Reference.cs from the .tt file

parydnar commented 1 year ago

Same description as @vendettamit, I have the same issue when running Visual Studio 2022, and the "OData Connected Service 2022+" version of this extension against a D365 Finance & Operations OData endpoint.

In VS2022, I deleted the OData Connected Service completely, and then re-added a new Connected Service, with the following Advanced Options selected: image

Running the Reference.tt produces the error:

An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find file '<SOLUTION_PATH_HERE>\Microsoft.OData.ConnectedService.dll'.
File name: '<SOLUTION_PATH_HERE>\Microsoft.OData.ConnectedService.dll'
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.StandardFileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share)
   at Roslyn.Utilities.CommonCompilerFileSystemExtensions.OpenFileWithNormalizedException(ICommonCompilerFileSystem fileSystem, String filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()
   at System.Linq.Enumerable.<UnionIterator>d__67`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
   at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.PrepareNewCompilation()
   at Microsoft.VisualStudio.TextTemplating.CompilerBridge.Compile()
   at Microsoft.VisualStudio.TextTemplating.TransformationRunner.Compile(String source, String inputFile, IEnumerable`1 references, Boolean debug, SupportedLanguage language, String compilerOptions)

Running VS 2019, as well as the older "OData Connected Service" extension, I can generate the Reference files/classes (but then also run into the #317 issue, for which it seems like there is a manual fix.)

jonantoine commented 1 year ago

My settings are like @parydnar as well. Using the older extension in VS2019 gets around the error for me, but is very annoying, specially I don't have VS2019 installed on all my workstations. So I end up committing and pulling to different workstations to keep going.

ElizabethOkerio commented 1 year ago

@jonantoine we are looking into this issue. But we have a cli tool that you can use - https://www.nuget.org/packages/Microsoft.OData.Cli/

jgenunez commented 1 year ago

@jonantoine we are looking into this issue. But we have a cli tool that you can use - https://www.nuget.org/packages/Microsoft.OData.Cli/

Is any other workaround available? Our use case requires T4 templates to customize property names, but I see no option to include T4 templates in Odata CLI.

jonantoine commented 1 year ago

@ElizabethOkerio We also have changed the T4 templates for better tracking of set properties.

jantoineqci commented 1 year ago

Wonderful! When will this get released to the marketplace? I'm eager to see if this fixing our problem.

jantoineqci commented 1 year ago

@ElizabethOkerio just wondering when this will get released to the marketplace? The marketplace says the last update was 2/3/2023.

ElizabethOkerio commented 1 year ago

@jantoineqci we'll do a release tomorrow.

jantoineqci commented 1 year ago

@ElizabethOkerio Thank you, we updated our VS2022 Extension. We had to update the ODataT4CodeGenFilesManager.ttinclude file inside our solution, but now the t4 templates work inside VS2022! image

image