docopt.net
docopt.net copied to clipboard
Exception when using in VS2015...
Hi,
While pulling from NuGet I get the following exceptionj. Same occurrs if I run the T3DocoptNet.tt T4 template.
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 'D:\Data\TFS\Ozcruising\VS 2015\OzCruisingImporters\Csv\OzCsvImporter\packages\docopt.net.0.6.1.6DocoptNet.dll'.
File name: 'D:\Data\TFS\Ozcruising\VS 2015\OzCruisingImporters\Csv\OzCsvImporter\packages\docopt.net.0.6.1.6DocoptNet.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 System.IO.File.OpenRead(String path)
at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
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__66`1.MoveNext()
at System.Linq.Enumerable.<UnionIterator>d__66`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.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable`1 items)
at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable`1 references)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable`1 references)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable`1 newReferences)
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) 1
Can you please try the latest version 0.6.1.8?
Hi,
While pulling from NuGet I get the following exceptionj. Same occurrs if I run the T3DocoptNet.tt T4 template.
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
'D:\Data\TFS\Ozcruising\VS
2015\OzCruisingImporters\Csv\OzCsvImporter\packages\docopt.net.0.6.1.6DocoptNet.dll'.
File name: 'D:\Data\TFS\Ozcruising\VS
2015\OzCruisingImporters\Csv\OzCsvImporter\packages\docopt.net.0.6.1.6DocoptNet.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 System.IO.File.OpenRead(String path)
at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String
path, MetadataReferenceProperties properties, DocumentationProvider
documentation)
at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String
x)
at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Enumerable.<UnionIterator>d__66
1.MoveNext()
at System.Linq.Enumerable.<UnionIterator>d__661.MoveNext() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable
1 source)
at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable1 items) at Microsoft.CodeAnalysis.ImmutableArrayExtensions.AsImmutableOrEmpty[T](IEnumerable
1
items)
at Microsoft.CodeAnalysis.Compilation.ValidateReferences[T](IEnumerable1 references) at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.WithReferences(IEnumerable
1
references)
at Microsoft.CodeAnalysis.CSharp.CSharpCompilation.CommonWithReferences(IEnumerable1 newReferences) 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) 1
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/docopt/docopt.net/issues/26, or mute the thread https://github.com/notifications/unsubscribe/AA9AMOTcIwaCSG44Ls8w7UZ7-_5KQpgbks5qLkLlgaJpZM4I0_FU .
The template stuff is still badly broken even in the latest 0.6.1.9 packages - definitely for VS2015, and probably for other versions of VS too, given the nature of the problem.
Brand new VS2015 console app project, add the docopt package, and it will immediately fail as it tries to build post-install:
Error An exception was thrown while trying to compile the transformation code. The following Exception was thrown:
System.IO.FileNotFoundException: Could not find file 'E:\dev\scratch\docoptBug\docoptBug\bin\Debug\DocoptNet.dll'.
File name: 'E:\dev\scratch\docoptBug\docoptBug\bin\Debug\DocoptNet.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 System.IO.File.OpenRead(String path)
at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
at Microsoft.VisualStudio.TextTemplating.CompilerBridge.<>c.<.ctor>b__15_0(String x)
The pathing is correct - the problem seems to simply be that, at the point that the template transform attempts to run, DocoptNet.dll
has not yet been copied to the output directory and so doesn't exist there. This is true at the point of the nuget package being added, and true on any attempt to build afterwards. The DLL won't exist in the output directory until after a successful, post-docopt-install build, but the build fails because the template transform does, so it's a catch 22.
If it was using the actual package path, it would presumably work. It seems like it used to use the package path - natiki's initial report shows error output that is indeed using the packaged path, and it seems to have been failing due to a simple typo which omits a necessary slash between the dir and the DLL name:
System.IO.FileNotFoundException: Could not find file 'D:\Data\TFS\Ozcruising\VS 2015\OzCruisingImporters\Csv\OzCsvImporter\packages\docopt.net.0.6.1.6DocoptNet.dll'.
Not sure what happened here - seems like the original problem that this issue described was a simple fix, but instead (or for separate reasons afterward?) things got switched up to use the project output path - which is always going to fail for any project which doesn't already have DocoptNet.dll
in the project output, at least so long as the template transform is happening before the copying of DLLs to the output dir has happened.
Need to look into this again
Happy to help test any changes (on VS2015 and VS2013).
I know that public package maintenance is no dev's idea of a good time, but I think it's worth considering whether the T4 templating stuff should maybe be spun off into a separate nuget package. Automatic generation of strongly-typed config classes is great if you want or need it, but Docopt is quite useful without out; others who've been hoping to see it made available in the form of a single Docopt.cs
source file seem to be on the same page.
It right away struck me as a bit odd that a lib that's otherwise so minimalistic and easy to use would have a package that's so prescriptive - dropping all of the following files in the project root:
Main.usage.txt
T4DocoptNet.tt
T4DocoptNet.tt.hooks.t4
T4DocoptNet.tt.settings.xml
and then making the build dependent on the transform, while requiring Main.usage.txt
to be edited for what it's doing to be at all useful. That's quite a different and more complex thing that the straightforward examples that the bulk of the main README.rst
describes... why not keep the main package nice and simple (in keeping with the library itself) instead?
I agree with you. My intention at the time was to improve the developer experience, but it looks like it backfired. In hindsight I should have packaged the t4 stuff separately. If you have a PR I would be interested to see what you have in mind.
Is this fixed? - I'm still seeing this error with VS2017.
I confess I did not look at this in ages and I agree with @discord that the library could be simplified. Unfortunately I have zero bandwidth for this at the moment...
On Thu 16 Jul 2020 at 20:47, Adrian Sims [email protected] wrote:
Is this fixed? - I'm still seeing this error with VS2017.
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/docopt/docopt.net/issues/26#issuecomment-659631257, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHUAMDMDTBNKGKWD5GD6VLR35KM3ANCNFSM4CGT6FKA .