I am having troubles getting my MSBuild script transform a .tt file that references EF.Utility.CS.ttinclude.
If i run the generation from within VS2010 it works fine, but when I run my custom build script via the command line I get.
TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"
C:\SourceControl\SVN\PathToFile\myttFile.tt(9,4): error : There was an error loading the include file 'EF.Utility.CS.ttinclude'. The transformation will not be run. The following Exception was thrown: [C:\SourceControl\SVN\PathToBuildScript\build.xml]
System.IO.FileNotFoundException: Could not find file 'C:\SourceControl\SVN\PathToFile\EF.Utility.CS.ttinclude'.
File name: 'C:\SourceControl\SVN\PathToFile\EF.Utility.CS.ttinclude'
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)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.ReadFileContent(String fileName)
at Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost.LoadIncludeText(String requestFileName, String& content, String& location)
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessIncludeDirective(Directive directive, ITextTemplatingEngineHost host)
C:\SourceControl\SVN\PathToBuildScript\build.xml(30,5): error MSB3073: The command "TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"" exited with code 1.
If I reference the absolute path for the EF.Utility.CS.ttinclude, I get:
TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"
EXEC : error : An expression block evaluated as Null [C:\SourceControl\SVN\PathToBuildFile\build.xml]
at Microsoft.VisualStudio.TextTemplating.ToStringHelper.ToStringWithCulture(Object objectToConvert)
at Microsoft.VisualStudio.TextTemplatinga265b58e2b114039856ebd504775f376.GeneratedTextTransformation.TransformText() in c:\SourceControl\SVN\PathToFile\myttFile.tt:line 77
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)
C:\SourceControl\SVN\PathToBuildFile\build.xml(30,5): error MSB3073: The command "TextTransform "C:\SourceControl\SVN\PathToFile\myttFile.tt"" exited with code 1.
Any help would be great :)
In short: Add the -I flag in TextTransform.exe to solve this problem like so:
Step 1:
Create an environment variable mapping to your TextTransform's EF6 Include like so:
which will create a variable VS140COMNTXTTRANSFORM that Windows understands
Step 2:
Include -I flag in the TextTransform.exe command like so:
TextTransform.exe -I "%VS140COMNTXTTRANSFORM%" -out filename.tt
Appears that the template you were running myttFile.tt failed out output anything as a result of the template being executed TransformText();
Can't really tell much without seeing what the logic is inside of myttFile.tt.
Visual Studio 11 if you
set <# template debug = true#>
and add
System.Diagnostics.Debugger.Launch();
to the code section of your template, VS 11 will launch the debugger and you can debug your t4.
sorry, just dawned on me. Chances are your template has a dependency on visual studio as its host. somewhere in your templates you have hostspecific = true.
<## template hostspecific="true" language="C#" #>
Related
I'm running an Azure Function locally in Visual Studio but receive the error "Could not find file 'C:\Users\kbiondi\AppData\Local\AzureFunctionsTools\Releases\4.13.0\cli_x64\Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream'. (details below).
The code that triggers this error seems to be:
let! parameters = JsonTypeProvider.AsyncLoad(req.Body.ToString())
Using let parameters = JsonTypeProvider.Load(req.Body) the function runs without problem.
I have reloaded various nuget packages and the sdk, but this problem persists.
Azure Functions Core Tools Core Tools Version: 4.0.4483 Commit
hash: N/A (64-bit) Function Runtime Version: 4.1.3.17473
[2022-05-19T18:24:10.578Z] Csproj not found in
C:\Users\kbiondi\OneDrive -
CalPERS\Repos\AzFunction_BpipeRefData\bin\Debug\net6.0 directory tree.
Skipping user secrets file configuration.
Functions:
BpipeReferenceDataRequest: [GET,POST] http://localhost:7071/api/BpipeReferenceDataRequest
For detailed output, run func with --verbose flag.
[2022-05-19T18:24:16.773Z] Host lock lease acquired by instance ID
'0000000000000000000000001F77FD18'. [2022-05-19T18:24:43.597Z]
Executing 'BpipeReferenceDataRequest' (Reason='This function was
programmatically called via the host APIs.',
Id=13a1beaf-3141-4112-a086) The Azure Function Received a
Request... Request failed with the following error:
Message: Could not find file
'C:\Users\kbiondi\AppData\Local\AzureFunctionsTools\Releases\4.13.0\cli_x64\Microsoft.AspNetCore.WebUtilities.FileBufferingReadStream'.
Source: System.Private.CoreLib
TargetSite: Microsoft.Win32.SafeHandles.SafeFileHandle
CreateFile(System.String, System.IO.FileMode, System.IO.FileAccess,
System.IO.FileShare, System.IO.FileOptions)
StackTrace: at
Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath,
FileMode mode, FileAccess access, FileShare share, FileOptions
options) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String
fullPath, FileMode mode, FileAccess access, FileShare share,
FileOptions options, Int64 preallocationSize) at
System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode
mode, FileAccess access, FileShare share, FileOptions options, Int64
preallocationSize) at
FSharp.Data.Runtime.IO.asyncRead#219-9.Invoke(Unit unitVar) at
Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation1 ctxt, TResult result1, FSharpFunc2 part2) in
D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line 447 at
BpipeProcess.BpipeReferenceDataRequest.Pipe #1 input at line
16#21-11.Invoke(AsyncActivation1 ctxt) at BpipeProcess.BpipeReferenceDataRequest.Pipe #1 input at line 16#20-14.Invoke(AsyncActivation1 ctxt) at
Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)
in D:\a_work\1\s\src\fsharp\FSharp.Core\async.fs:line
104[2022-05-19T18:24:43.679Z] Executed 'BpipeReferenceDataRequest'
(Succeeded, Id=13a1beaf-3141-4112-a086, Duration=101ms)
Based on the MICROSOFT DOCUMENTATION:-
F# script (.fsx) is only supported by version 1.x of the Azure
Functions runtime. If you want to use F# with version 2.x and later
versions of the runtime, you must use a precompiled F# class library
project (.fs). You create, manage, and publish an F# class library
project using Visual Studio .
You can use in that line if wants http request e.g:- let Run(req: HttpRequestMessage, log: ILogger) =
And make sure that your folder structure looks like below format:
FunctionsProject
| - MyFirstFunction
| | - run.fsx
| | - function.json
| | - function.proj
| - MySecondFunction
| | - run.fsx
| | - function.json
| | - function.proj
| - host.json
| - extensions.csproj
| - bin
For more information please refer the aforementioned and below links:
SIMILAR ISSUE|SO THREAD
MICROSOFT DOCUMENT|Microsoft.AspNetCore.WebUtilities Namespace
BLOG|Microsoft.AspNetCore.WebUtilities FileBufferingReadStream Examples
I want to test my code with some data defined in an external file.
I tried the following:
namespace blub
open System
open Microsoft.VisualStudio.TestTools.UnitTesting
[<TestClass>]
type TestClass () =
[<TestMethod>]
member this.TestMethodPassing () =
let txt = System.IO.File.ReadAllText "data.txt"
Assert.IsTrue(txt.Contains "Hello");
I just created the project with dotnet new mstest -lang F# and put the data.txt file next to the Test.fs file.
However, when I run the tests with dotnet test I get the following error:
Failed TestMethodPassing
Error Message:
Test method blub.TestClass.TestMethodPassing threw exception:
System.IO.FileNotFoundException: Could not find file '/home/peter/Desktop/blub/bin/Debug/netcoreapp2.1/data.txt'.
Stack Trace:
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at blub.TestClass.TestMethodPassing() in /home/peter/Desktop/blub/Tests.fs:line 11
I can of course fix this by changing the path to "../../../data.txt", but this does not seem like a stable solution -- I did not find any documentation that states how test execution affects the current directory.
Can I somehow declare my test file as a resource to be copied to the correct folder?
You will need to add the data.txt file to the fsproj and set it to copy to the output folder:
<ItemGroup>
<Content Include="data.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
If it still isn't found, you may you need to use the [<DeploymentItem("data.txt")>] against the TestClass.
This will copy the files from the output folder to the folder where the tests are executed.
I'm running a .NET Core application which utilizes AWSSDK.Core. However, I'm getting an exception when running the following code on Mac or a Docker linux container (microsoft/dotnet:1.0.1-sdk-projectjson):
ProfileManager.RegisterProfile(_config.Aws.Credentials.ProfileName, _config.Aws.Credentials.AccessKey, _config.Aws.Credentials.Secret);
Here is the exception:
System.DllNotFoundException: Unable to load DLL 'Crypt32.dll': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
at Amazon.Runtime.Internal.Settings.UserCrypto.CryptProtectData(DATA_BLOB& pDataIn, String szDataDescr, DATA_BLOB& pOptionalEntropy, IntPtr pvReserved, CRYPTPROTECT_PROMPTSTRUCT& pPromptStruct, CryptProtectFlags dwFlags, DATA_BLOB& pDataOut)
at Amazon.Runtime.Internal.Settings.UserCrypto.Encrypt(String unencrypted)
at Amazon.Runtime.Internal.Settings.SettingsCollection.ObjectSettings.WriteToJson(JsonWriter writer)
at Amazon.Runtime.Internal.Settings.SettingsCollection.Persist(StreamWriter writer)
at Amazon.Runtime.Internal.Settings.PersistenceManager.saveSettingsType(String type, SettingsCollection settings)
at Amazon.Util.AWSCredentialsProfile.Persist(String profileName, String accessKeyId, String secretKey)
My dependecies are as follows:
"dependencies": {
"AWSSDK.Core": "3.3.5"
}
It looks like the ProfileManager is only supported on Windows.
https://github.com/aws/aws-sdk-net/issues/507#issuecomment-265607037
Last night while attempting to upgrade from TFS 2013 RTM to TFS 2013.2 I received the following error. I ran the installation as administrator, I am the TFS Administrator for our organization and I ran the upgrade from TFS 2013 RTM to TFS 2013.2 in our staging environment without issue. The only difference in the two environments is the collection DBs are not exactly the same.
[Error #22:27:44.807]
Exception Message: TF255077: The access control list (ACL) could not be set on the following path: D:\TFS\CacheRoot . (type ConfigurationException)
Exception Stack Trace: at Microsoft.TeamFoundation.Admin.FileSystemHandler.SetAcls(String[] identities, String[] pathsForAccess, Boolean skipIfAclExists, ITFLogger logger)
at Microsoft.TeamFoundation.Admin.ConfigureSetAcls.Run(ActivityContext context)
Inner Exception Details:
Exception Message: Invalid name.
Parameter name: name (type ArgumentException)
Exception Stack Trace: at System.Security.AccessControl.NativeObjectSecurity.CreateInternal(ResourceType resourceType, Boolean isContainer, String name, SafeHandle handle, AccessControlSections includeSections, Boolean createByName, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
at System.Security.AccessControl.NativeObjectSecurity..ctor(Boolean isContainer, ResourceType resourceType, String name, AccessControlSections includeSections, ExceptionFromErrorCode exceptionFromErrorCode, Object exceptionContext)
at System.Security.AccessControl.DirectorySecurity..ctor(String name, AccessControlSections includeSections)
at System.IO.Directory.GetAccessControl(String path)
at Microsoft.TeamFoundation.Admin.FileSystemHandler.AddAccessToDirectory(String groupName, FileSystemRights rights, String path, Boolean skipIfAclExists, ITFLogger logger)
at Microsoft.TeamFoundation.Admin.FileSystemHandler.SetAcls(String[] identities, String[] pathsForAccess, Boolean skipIfAclExists, ITFLogger logger)
[Info #22:27:44.807] Node returned: Error
[Error #22:27:44.807] TF255077: The access control list (ACL) could not be set on the following path: D:\TFS\CacheRoot .
[Info #22:27:44.807] Completed SetApplicationACLs: Error
[Info #22:27:44.807] -----------------------------------------------------
[Info #22:27:44.808] Execution results:
[Info #22:27:44.808] Overall result: Failure
It was discovered that there were spaces on either end of the folder location entry in the web.config file in the following location; C:\Program Files\Microsoft Team Foundation Server 12.0\Application Tier\Web Services.
add key="dataDirectory" value=" D:\TFS\CacheRoot "
I removed the spaces and the installation worked perfectly. I have no idea how they got there but it is my assumption that the original TFS 2013 RTM installation may have done this as I pointed the installation to that folder when given the option during setup.
Brief summary:
When I add System.Web.WebPages.dll to bin folder of my app, .NET framework in my web app starts producing "Illegal characters in path." crash on requests like this:
http://qa.postjobfree.com/autocompleteskills/%22myskill
When I remove System.Web.WebPages.dll from bin folder - the error is gone.
Why does it happen?
Below are clarifying details in Q&A form.
Q1: Why do you add System.Web.WebPages.dll to bin folder if System.Web.WebPages.dll is already part of .NET framework?
Because I want to add MVC to my existing Web Forms application.
Newest version MVC requires System.Web.WebPages.dll (and 5 more DLLs) to be added to bin folder.
Q2: Did you try setting relaxedUrlToFileSystemMapping flag?
Yes. Thanks to Scott Hanselman and multiple answers on Stack overflow, I added this configuration to my Web.Config:
<system.web>
<httpRuntime requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true" requestPathInvalidCharacters="" maxRequestLength="8192" />
</system.web>
I added it several years ago and it fixed "Illegal characters in path." crash.
Now when I'm adding System.Web.WebPages.dll to web app bin folder - Hanselman's solution does not help anymore and I'm getting that crash again.
Here's possible hint to solving the problem: requestPathInvalidCharacters flags were not supported prior to .NET 4.0 (circa 2010).
Q3: Does that "Illegal characters in path." crash happen on all computers?
No.
Unfortunately it crashes in production, but does not crash on my dev machine.
Q4: What's the difference between your production machine and your dev machine?
Production machine has Windows Server 2012 R2
Microsoft Windows [Version 6.3.9600]
Development machine has Windows 7
Microsoft Windows [Version 6.1.7601]
Development machine has Microsoft Visual Studio 2013 installed.
Production only has .NET Framework 4.5.1 (the same as development).
But the most relevant difference between production and development machines is in System.Web.WebPages.dll version that is installed to GAC.
In my research I discovered 3 different versions of System.Web.WebPages.dll:
v1
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll
Size: 136,552 bytes
File version: 1.0.20105.407
Product version: 1.0.20105.407
v2
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll
Size: 204,480 bytes
File version: 2.0.20710.0
Product version: 2.0.20710.0
v3
C:\dennis\projects\ijs\PostJobFreeWeb\bin\System.Web.WebPages.dll
Size: 211,664 bytes
File version: 3.0.20129.0
Product version: 3.0.1-20129
I have v1 in GAC on my production machine.
I have v2 in GAC on my development machine.
I got v3 from MVC nuget package and put it into bin folder of my web app.
Q5: Did you try putting different versions of DLLs into bin folder?
Yes I did.
I found out that putting v1 into bin folder on production machine does NOT cause "Illegal characters in path." crash.
I found out that putting either v2 or v3 into bin folder causes "Illegal characters in path." crash.
So, basically, if dll in bin folder matches with dll in GAC - there is no problem.
But if there is a mismatch - then web project misbehaves.
I also tried to put v1 dll into bin folder on my development machine (dev machine has v2 in GAC). That did NOT cause any problems.
Q6: Error Stack trace?
Message:
Illegal characters in path.
Type: System.ArgumentException
Stack:
at System.IO.Path.Combine(String path1, String path2)
at System.Web.Compilation.DiskBuildResultCache.GetBuildResult(String cacheKey, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.WebPages.BuildManagerWrapper.ExistsInPrecompiledSite(String virtualPath)
at System.Web.WebPages.VirtualPathFactoryManager.Exists(String virtualPath)
at System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func`2 virtualPathExists)
at System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, IDisplayMode currentDisplayMode, Boolean requireConsistentDisplayMode)
at System.Web.WebPages.WebPageRoute.GetRouteLevelMatch(String pathValue, String[] supportedExtensions, Func`2 virtualPathExists, HttpContextBase context, DisplayModeProvider displayModeProvider)
at System.Web.WebPages.WebPageRoute.MatchRequest(String pathValue, String[] supportedExtensions, Func`2 virtualPathExists, HttpContextBase context, DisplayModeProvider displayModes)
at System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)