Where is TextTransform.exe Located on Hard drive? - t4

Where is TextTransform.exe located?
I'm trying to implement the solution in this post:
Get Visual Studio to run a T4 Template on every build
However I'm getting an error
"'TextTransform.exe' is not recognized as an internal or external command,
operable program or batch file."
I have been looking through the program files, however not sure where TextTransform.exe is located.

It should be below
\Program Files\Common Files\Microsoft Shared\TextTemplating\
see: http://msdn.microsoft.com/en-us/library/bb126245.aspx

Anyone coming to this question that's using VS 2017 or later should be using vswhere to locate this file. #codingdave's comment is the closest but that still won't work on many computers.
I've added an example to the Microsoft Docs article feedback that shows how to do this with Powershell.
#the path to VSWhere.exe is always in programfiles(x86)
$progFilesx86Path = [System.Environment]::ExpandEnvironmentVariables("%programfiles(x86)%")
$vsWherePath = Join-Path $progFilesx86Path "\Microsoft Visual Studio\Installer\vswhere.exe"
# this tells vswhere to use paths of the latest version of visual studio installed
# to locate this exe anywhere in those paths, and return a single textual
# value (not a json object or xml payload)
$ttExe = & $vsWherePath -latest -find **\TextTransform.exe -format value
if (-Not(Test-Path $ttExe)){
throw "Could not locate TextTransform.exe"
}
#then to invoke a transformation
& "$ttExe" c:\Source\YourTransform.tt

From #codingdave's comment
For VS2017, VS2019 location of TextTransform.exe will be
C:\Program Files (x86)\Microsoft Visual Studio\<<Version>>\<<Edition>>\Common7\IDE
Version -> (2017/2019)
Edition -> (Community/Professional/Enterprise)
And in pre build event we can use macro like
"$(DevEnvDir)\TextTransform.exe" "$(ProjectDir)AssemblyInfo.tt"

I would recommend trying this over that solution: http://www.olegsych.com/2010/04/understanding-t4-msbuild-integration
If you don't have VS 2010, though, I suppose you're stuck doing it the hard way.

Related

VS2015 compile errors with Win API GetIscsiSessionList of Iscsidsc.h

I want to user a Windows API called GetIscsiSessionList to get the information of session list.
I came across with a compile problem, VS2015 complains as follows:
VS complians of GetIscsiSessionList:
VS complians in header file Iscsidsc.h:
Iscsidsc.h is in C:\Program Files (x86)\Windows Kits\8.1\Include\um
. Since Iscsidsc.h is a Windows provided file, I don't understand why VS compiler will complain.
The order of include header files should be as follows:
iscsierr.h should be in front of iscsidsc.h

When running mstest under OpenCover, I get an error regarding the .vsmdi.trx file

I am having a problem when trying to run a VS10 test suite through OpenCover, using mstest as my target application.
Running the tests directly with MsTest works with this command:
"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /resultsfile:"<application_root_path>\UnitTestResults\MyProject.vsmdi.trx" /testmetadata:"MyProject.vsmdi" /testlist:"ServiceTests" /testlist:"DatabaseTests"
However, when trying to run the same command under OpenCover, like this:
OpenCover\Opencover.console.exe -register:user -target:"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" -targetargs:"/resultsfile:"<application_root_path>\UnitTestResults\MyProject.vsmdi.trx" /testmetadata:"MyProject.vsmdi" /testlist:"ServiceTests" /testlist:"DatabaseTests"" -output:<application_root_path>\UnitTestResults\Coverage
it fails, with the following error, regarding the .vsmdi.trx file (which I gather should be created by MsTest after the tests run):
Error occurred while loading document '<application_root_path>\UnitTestResults\MyProject.vsmdi.trx'.
Code: 0x800c0006
The system cannot locate the object specified.
So, basically, it complains that it cannot find the results file, before running the tests, but that file is supposed to be created at the end of the run.
Might this be an issue related to OpenCover, as the same params work when running directly with mstest?
I checked my paths and they all work out, even the one in the error is the path where the file should be generated by mstest.
Thanks.
It looks like you may need to escape your quotes when passing your data via targetargs
-targetargs:"/resultsfile:"<application...""
becomes
-targetargs:"/resultsfile:\"<application...\""
as detailed in the wiki on handling spaces.
Alternatively put your command to execute your tests in a cmd/bat file and then use opencover to execute that.

How to fix Setup project Prerequisites warning

When I go to the "Setup Property Pages" in a Visual Studio Setup project and view the Prerequisites, I see a warning:
Prerequisite could not be found for bootstrapping
I did the following things:
Added a new folder in: "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages" with my package
Restarted VS2010
(Even rebooted my pc)
Warning is still visible on that package.
Next I've added a .VSBootstrapperManifest file in the Packages directory ( C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages )
Restarted VS2010 again but that didn't help either, same with reboot.
Any suggestion what could be wrong?
This worked on my Win7 x64 machine, but this doesn't seem to work anymore on my Win8 Pro x64.
Thanks in advance.
update:
When I open the Product.xml file from my package I see these XML lines:
<InstallChecks>
<RegistryCheck Property="FoxProOleDbInstalled" Key="HKCR\CLSID\{...-..-..}\InprocServer32" />
</InstallChecks>
When I search that key {...-..-..} in my registry I cannot find it at the location HKCR\CLSID{...-..-..}
But I can find it at this location:
HKEY_CLASSES_ROOT\ Wow6432Node \CLSID\ {...-..-..}
Can I just add another line inside the InstallChecks-tag in the Product.xml ?
How will the RegistryCheck tags be checked in that file (AND? OR?)
(I think all InstallChecks need to be true but I'm not sure, the documentation is not so clear: http://msdn.microsoft.com/en-us/library/ms229432(v=vs.80).aspx )
If you are developing windows 8 store/metro apps in "windows 8 pro".
Use visual studio 2012 instead of vs2010.It will work.

Visual 2010 MFC new project doesn't build!

I just created a new project in Visual 2010. It is a multi-document MFC (static link) application with the HTML help option, Visual Studio 2008 style (with style changing option), that's about it.
Just after creation, I hit Build Solution and I get a lot build errors all in afxcomctl32.h. Errors like:
Error 1 error C2061: syntax error : identifier 'LPCWS' C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\afxcomctl32.h 426 1
On this line:
AFX_ISOLATIONAWARE_STATICLINK_FUNC(HWND ,CreateWindowExW,(DWORD dwExStyle,LPCWS TR lpClassName,LPCWSTR lpWindowName,DWORD dwStyle,int X,int Y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam),(dwExStyle,lpClassName,lpWindowName,dwStyle,X,Y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam),NULL)
Same errors in Debug and Release.
My PC is Windows 7 Ultimate. What's the problem???
Best regards,
Downy
AFX_ISOLATIONAWARE_STATICLINK_FUNC(..., LPCWS TR lpClassName, ...)
That code got messed up, there is a space or tab inserted in LPCWSTR. Deleting it will fix the problem.
However, that changed the timestamp on the file as well, you may run into trouble when you install a future service pack. One thing to try is to rename the file, then run a Repair to get the original file back. Or copy it off another machine.

Vim errorformat for Visual Studio

I want to use Vim's quickfix features with the output from Visual Studio's devenv build process or msbuild.
I've created a batch file called build.bat which executes the devenv build like this:
devenv MySln.sln /Build Debug
In vim I've pointed the :make command to that batch file:
:set makeprg=build.bat
When I now run :make, the build executes successfully, however the errors don't get parsed out. So if I run :cl or :cn I just end up seeing all the output from devenv /Build. I should see only the errors.
I've tried a number of different errorformat settings that I've found on various sites around the net, but none of them have parsed out the errors correctly. Here's a few I've tried:
set errorformat=%*\\d>%f(%l)\ :\ %t%[A-z]%#\ %m
set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
set errorformat=%f(%l,%c):\ error\ %n:\ %f
And of course I've tried Vim's default.
Here's some example output from the build.bat:
C:\TFS\KwB Projects\Thingy>devenv Thingy.sln /Build Debug
Microsoft (R) Visual Studio Version 9.0.30729.1.
Copyright (C) Microsoft Corp. All rights reserved.
------ Build started: Project: Thingy, Configuration: Debug Any CPU ------
c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.Linq.dll" /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationProvider.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\Thingy.exe /resource:obj\Debug\Thingy.g.resources /resource:obj\Debug\Thingy.Properties.Resources.resources /target:winexe App.xaml.cs Controller\FieldFactory.cs Controller\UserInfo.cs Data\ThingGatewaySqlDirect.cs Data\ThingListFetcher.cs Data\UserListFetcher.cs Gui\FieldList.xaml.cs Interfaces\IList.cs Interfaces\IListFetcher.cs Model\ComboBoxField.cs Model\ListValue.cs Model\ThingType.cs Interfaces\IThingGateway.cs Model\Field.cs Model\TextBoxField.cs Model\Thing.cs Gui\MainWindow.xaml.cs Gui\ThingWindow.xaml.cs Interfaces\IField.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs RequiredValidation.cs "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\FieldList.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\MainWindow.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\Gui\ThingWindow.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\App.g.cs" "C:\TFS\KwB Projects\Thingy\Thingy\obj\Debug\GeneratedInternalTypeHelper.g.cs"
C:\TFS\KwB Projects\Thingy\Thingy\Controller\FieldFactory.cs(14,19): error CS0246: The type or namespace name 'IFieldNothing' could not be found (are you missing a using directive or an assembly reference?)
Compile complete -- 1 errors, 0 warnings
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
UPDATE:
It looks like using msbuild instead of devenv is probably the right way to go (as per Jay's comment).
Using msbuild the makeprg would be:
:set makeprg=msbuild\ /nologo\ /v:q
Sample output whould be:
Controller\FieldFactory.cs(14,19): error CS0246: The type or namespace name 'IFieldNothing' could not be found (are you missing a using directive or an assembly reference?)
It looks like the tricky part here may lie in the fact that the path is relative to the .csproj file, not the .sln file which is the current directory in Vim and lies one directory above the .csproj file.
ANSWER:
I figured it out...
set errorformat=\ %#%f(%l\\\,%c):\ %m
This will capture the output for both devenv /Build and msbuild.
However, msbuild has one catch. By default, it's output doesn't include full paths. To fix this you have to add the following line to your csproj file's main PropertyGroup:
<GenerateFullPaths>True</GenerateFullPaths>
I have a blog post which walks through all the details of getting C# projects building in Vim, including the error format. You can find it here: http://kevin-berridge.blogspot.com/2008/09/vim-c-compiling.html
In short you need the following:
:set errorformat=\ %#%f(%l\\\,%c):\ %m
:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true
Copy from question to remove from 'unanswered' list
set errorformat=\ %#%f(%l\\\,%c):\ %m
This will capture the output for both devenv /Build and msbuild. However, msbuild has one catch. By default, it's output doesn't include full paths. To fix this you have to add the following line to your csproj file's main PropertyGroup:
<GenerateFullPaths>True</GenerateFullPaths>
I found an even better answer: use :compiler to use built-in efm settings.
" Microsoft C#
compiler cs
" Microsoft Visual C++
compiler msvc
" mono
compiler mcs
" gcc
compiler gcc
Note: It also sets the default makeprg. See $VIMRUNTIME/compiler/
Try running msbuild instead of devenv. This will open up a ton of power in how the build runs.
Open a Visual Studio Command Prompt to get your path set up. Then do msbuild MySln.sln /Configuration:Debug.
See msbuild /? for help.
I found this question when looking for errorformat for compiling c++ in Visual Studio. The above answers don't work for me (I'm not using MSBuild either).
I figured out this from this Vim Tip and :help errorformat:
" filename(line) : error|warning|fatal error C0000: message
set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m
Which will give you a quickfix looking like this:
stats.cpp|604 error 2039| 'getMedian' : is not a member of 'Stats'
(with error highlighted) from
c:\p4\main\stats.cpp(604) : error C2039: 'getMedian' : is not a member of 'Stats'
As Simon Buchan mentioned you can use this in your project to generate the full paths in the output:
<GenerateFullPaths>True</GenerateFullPaths>
But you can make it more portable by adding /property:GenerateFullPaths=true to you makeprg instead of adding the above to your project files.
:set makeprg=msbuild\ /nologo\ /v:q\ /property:GenerateFullPaths=true\
None of these errorformats worked in Visual studio 2009 v9.0.21022.8 professional edition. Using cygwin, had to call devenv from bash which made setting makeprg a little tricky (screw batch files). Also had to tweak my errorformat when devenv splits into multiple processes and proceeds error message with "1>" or "2>" etc:
set autowrite
"2>c:\cygwin\home\user\proj/blah.cpp(1657) : error C2065: 'blah' : undeclared identifier
set errorformat=%.%#>\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %[A-Z\ ]%#%n:\ %m
let prg="devenv"
let makepath=$MAKEPATH
let &makeprg='cmd /c "'.prg.' '.makepath.'"'
My .bashrc sets the MAKEPATH environment variable using cygpath to convert to a DOS compatible path:
export MAKEPATH="$(cygpath -d "proj/VC9/some.sln") /build \"Debug\""
If you have vim 6.x you can use :cw which is SO much better than clist (try searching for errors among hundreds of warnings and you know what I mean). Looking at vim tweaks makes me want to vomit but I'm in vim heaven!!! Good bye visual studio! Thanks for the base to tweak pydave +1.

Resources