MSBuild add file to primary output - file

How can i add some custom file created by MSBuild to project output?
i.e. I have blank .csproj, I add Exec task to Target that generates some file.txt and now i want to include this file into "primary output" or "content files".
Thanks,
Marek

Generally, you just need to include the output files you have and then copy them to the output directory.
<CreateItem Include="$(SourcePath)\file.txt">
<Output ItemName="FilesToCopy" TaskParameter="Include" />
</CreateItem>
<Copy SourceFiles="#(FilesToCopy)" DestinationFolder="$(OutDir)" />
There's also a variable $(OutputDirectory) for the immediate project. There are many other properties you may find useful also:
https://msdn.microsoft.com/en-us/library/ms164309.aspx
https://msdn.microsoft.com/en-us/library/ms164313.aspx

Related

How to Log Teraterm into Text file by using Batch File

I am using Ttermpro.exe to run TTL file. After that, teraterm will display all the output. I want to insert the display in teraterm into logfile.txt by using batch file command. Any idea on how to resolve this problem?
"C:\Program Files (x86)\teraterm\ttermpro.exe" /L=C:\0465\PCU 90000465\UartLog.txt "C:\0465\PCU 90000465\COM.TTL"
I don't know if this answers your problem directly, but based on what I think you're saying, try:
In the teraterm ttl file, include this to avoid the logging command in TTermPro:
logopen 'C:\0465\PCU 90000465\UartLog.log' <binary flag> <append flag>
... more content
... and when done
logclose
The binary flag and append flag can both be set to zero, but you can find more info here: https://ttssh2.osdn.jp/manual/en/macro/command/logopen.html
Generally, I thought the log file was a .log extension, but if you really want it to become a .txt file, you could also add after the logclose function
filerename 'C:\0465\PCU 90000465\UartLog.log' 'C:\0465\PCU 90000465\UartLog.txt'
As far as the batch file goes, you'd simply change directories to the teraterm TTermPro executable and then run the command to execute the macro.
cd C:\Program Files\teraterm
TTERMPRO /M="C:\0465\PCU 90000465\COM.TTL"
but you can also achieve the same thing just using the TTPMacro as
cd C:\Program Files\teraterm
TTPMacro /M=C:\0465\PCU 90000465\COM.TTL
Just save one of those two sets of commands as a .bat file and that should hopefully work.

how to copy _PublishedWebsites Files?

In Fact, I use Visual Studio 2013, and I want to copy the _PublishedWebsites Files using a batch file after deployment of my build , so this is an image to my Build Definitions:
I'm using in the batch file, this command:
xcopy /s ...\_PublishedWebsites\subfolders ...\main\Service >> ...\output.txt
To be sure that the copy works well, I wrote the result of copying operation in output.txt, so the result is:
0 File(s) copied
I noticed that the copy operation was done before than the _Publishedfiles files are created.
Do you know how can I copy the _Publishedfiles files after their complilation ?
In addition, I don't have the rights for changing in .xaml files :(
Use publish profile and type file system which will copy _PublishedWebsites to sharelocation/location
for publish profile see
https://msdn.microsoft.com/en-us/library/dd465337%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
If you know _PublishedWebSites directory on build machine you can copy files to path you want . You can do something like this, i used this task for same issue.
<ItemGroup >
<MyProjectSource Include="$(OutputRoot)/MySource/**/*.*" />
</ItemGroup>
<Target Name="AfterCopy" AfterTargets="WebPublish">
<Copy SourceFiles="#(MyProjectSource)"
OverwriteReadOnlyFiles="true" DestinationFolder="$(PublishFolder)/% (RecursiveDir)"/>
OutputRoot = your _PublishedWebsites path
MySource = your project
PublishFolder = your destination folder
You can do like this in your csproj file or if you use tfs build definition you can add a copy file task step to defintion and just fill paramaters.

Where are the recorded macros stored in Notepad++?

I have recorded a macro that I want to share with my work colleague.
In what location are these recorded macros saved, so that I can add it to his machine?
If interested, the macro is for taking a list of values and adding quotes and comma so that it can be used in the WHERE clause of of an SQL query (WHERE x IN ('value1','value2','value3')).
In Windows the macros are saved at %AppData%\Notepad++\shortcuts.xml
(Windows logo key + E and copy&paste %AppData%\Notepad++\)
Or:
In Windows < 7 (including Win2008/R2) the macros are saved at C:\Documents and
Settings\%username%\Application Data\Notepad++\shortcuts.xml
In Windows 7|8|10
C:\Users\%username%\AppData\Roaming\Notepad++\shortcuts.xml
Note: You will need to close Notepad++ if you have any new macros you want to 'export'.
Here is an example:
<NotepadPlus>
<InternalCommands />
<Macros>
<Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
<Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
<Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
</Macro>
<Macro name="abc" Ctrl="no" Alt="no" Shift="no" Key="0">
<Action type="1" message="2170" wParam="0" lParam="0" sParam="a" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="b" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="c" />
</Macro>
</Macros>
<UserDefinedCommands>....
I added the 'abc' macro as a proof-of-concept.
For Windows 7 macros are stored at C:\Users\Username\AppData\Roaming\Notepad++\shortcuts.xml.
Hit F6
Insert::
npp_open $(PLUGINS_CONFIG_DIR)\..\..\shortcuts.xml
Click OK
You now have the file opened in your editor.
Before altering things checkout the related docs:
Task automation with macros | Notepad++ User Manual
Configuration Files Details | Notepad++ User Manual (section about the <macros> tag)
On Vista with virtualization on, the file is here. Note that the AppData folder is hidden. Either show hidden folders, or go straight to it by typing %AppData% in the address bar of Windows Explorer.
C:\Users\[user]\AppData\Roaming\Notepad++\shortcuts.xml
You can find the shortcuts.xml in AppData\Roaming\Notepad++\ path only when using the default settings. If you have backup configured, you can find and set the path in Preferences -> Backup -> Backup path.
When these settings are applied, files in AppData directory won't be used.
If you install Notepad++ on Linux system by wine (In my case desktop Ubuntu 14.04-LTS_X64) the file "shortcuts.xml" is under :
$/home/[USER-NAME]/.wine/drive_c/users/[USER-NAME]/My Documents/.wine/drive_c/Program Files (x86)/Notepad++/shortcuts.xml
Thanks to Harrison and all that have suggestions for that isssue.
Notepad++ will forget your macros unless you map them to hotkeys via Settings - Shortcut mapper - Macros before exiting Notepad++ (as per https://superuser.com/questions/332481/how-can-i-add-a-macro-in-notepad. Tested with Notepad v6.8.3 on Windows7.)
Go to %appdata%\Notepad++ folder.
The macro definitions are held in shortcuts.xml inside the <Macros> tag. You can copy the whole file, or copy the tag and paste it into shortcuts.xml at the other location.
In the latter case, be sure to use another editor, since N++ overwrites shortcuts.xml on exit.

File diff in MSBuild?

How do I diff two files in MSBuild? I cannot find any specific task to do it.
If possible, is it also possible to exclude certain rows, or patterns in the files eg.
2009-12-09T10:03:07.6888125+02:00
You're gonna have to write your own MSBuild task which wraps some difftool commandline app. For commandline apps, you can inherit from the ToolTask class, which provides quite a bit of command line plumbing.
<Target Name="CheckFileSyncStatus" BeforeTargets="Build" Inputs="#(FilesToSync -> '..\..\..\folder1\folder2\%(Filename)%(Extension)')" Outputs="#(FilesToSync)">
<Exec Command="FC "%(FilesToSync.Filename)%(FilesToSync.Extension)" "..\..\..\folder1\folder2\%(FilesToSync.Filename)%(FilesToSync.Extension)"">
<Output TaskParameter="ExitCode" PropertyName="FCExitCode" />
</Exec>
<Error Text="[HP.OneDriver.Win10S.DriverProperties]:Files out of sync from source: %(FilesToSync.Filename)%(FilesToSync.Extension)" Condition="FCExitCode == 1" />

How do I work with spaces in my wix source path?

wxs file the File tag Source attribute; the path has a space in it.
<File Id="_uploads.UserImport.EDS_UserImport.xls" Name="EDS_UserImport.xls" Source="C:\Documents and Settings\kle\Desktop\OspreyMSIGenerator\OspreyMSIGenerator\Published\EDSContainer\uploads\UserImport\EDS_UserImport.xls"></File>
I get this error
candle.exe : error CNDL0103 : The system cannot find the file 'and' with type 'Source'.
I can't be sure that my paths won't have spaces in it. How do I support spaces in the Source path?
Try upgrading to the latest stable wix release. I tested this with Wix 3.0.5419.0 and file paths with spaces are accepted without errors.
On a related note: File elements should not contain absolute paths like in your example, because you would only be able to build the setup on a single developer's PC. Use paths relative to the location of the wxs file instead, like this:
<File Source="..\bin\foo.exe" />
Or make use of a variable that contains the location of the files like this:
<File Source="$(var.BinFolder)foo.exe" />
You can then pass the location of the bin folder by invoking candle like this:
candle.exe -dBinFolder=c:\someFolder\bin\ foo.wxs
edit: as shown by Rob in his own answer, you can also use the light.exe -b switch to specify one or more base directories where the files to install can be found.
#wcoenen provides one mechanism. However, I prefer to use the light.exe -b switch. Then your code can look like:
<File Id="_uploads.UserImport.EDS_UserImport.xls" Name="EDS_UserImport.xls" Source="SourceDir\Published\EDSContainer\uploads\UserImport\EDS_UserImport.xls"></File>
and your command-line to light.exe would have:
-b "C:\Documents and Settings\kle\Desktop\OspreyMSIGenerator\OspreyMSIGenerator"
You can have multiple -b switches and greatly reduce the complexity of your Source attribute.
Also, the File/#Id and File/#Name can be left off if you are fine with them defaulting to the file name (in this case, "EDS_UserImport.xls").

Resources