How to add a file to MonoDevelop Packaging project - msbuild

This seems like a simple question, but I can't find it documented anywhere.
I'd like to add a ReadMe.txt file to the zipped binary archive in my MonoDevelop Packaging project.
I tried this:
<Package name="Linux Binaries">
<Builder targetFile="..\script-keeper-bin-linux.zip" platform="Linux" configuration="Release" ctype="BinariesZipPackageBuilder">
<ChildEntries>
<SolutionItemReference path="..\Keeper.OfScripts\Keeper.OfScripts.csproj" />
<!-- ************************************** -->
<!-- This is where I tried to add the file. -->
<SolutionItemReference path="..\Keeper.OfScripts\ReadMe.txt" />
</ChildEntries>
<ExcludedFiles>
<File>Keeper.OfScripts,ProgramFiles,System.Web.Mvc.dll</File>
</ExcludedFiles>
<RootEntry path="..\Keeper.OfScripts.sln" id=":root:" />
</Builder>
</Package>
But nothing got added (the package did build correctly, but it omitted the ReadMe.txt file).
Is this is same syntax as an MSBuild file? Either way, I can't find anything that helps.
Thanks.
Update:
Well, I thought I set the build-action to Content and properties to Copy to Output Directory for ReadMe.txt, but I didn't. If you set those things, then the file will be included in your package.
Doing so also checks the Include in deploy box in the file's property window.

The way packaging projects work is somewhat strange. The format is not currently compatible with MSBuild, despite the file header. Essentially, a packaging project only includes projects - the list of included projects can be edited in the package options. The files that are included from each project are controlled using the property grid when the files are selected in the solution tree. When the packaging project is built, it can generate several different kinds of package, but they all have the same sources.

Related

MSBuild not publishing dll.config of dependency for ClickOnce

My C# projectA published via ClickOnce depends on projectB. I need the projectB.dll.config file for projectA to work. While MSBuild copies over projectB.dll.config to projectA/bin/ConfigXY correctly, it is not published. VisualStudio (2017) doesn't even show the file in Application->Publish->Application Files.
As a workaround, I added this to A.csproj:
<Content Include="..\projectB\bin\Release\projectB.dll.config">
<Link>projectB.dll.config</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Now VS shows the file in the "Application Files" list, but this of course works only for the Release build config. Since I have lots of configs in project A that map to different configs in B, I cannot simple use $(Configuration) in the path.
I have found some suggestions to include ..\**\*.dll.config, but that seems dangerous, as when both the Debug and Release folder exist (from a previous build), I might end up with the wrong one.
What's the right way to do this?
I’d like to post this as a comment, but due to the limitations, I post it as an answer and I am sorry for that.
I did some tests, and it seems, to include the project.dll.config file to be published(shown in Application > Publish > Application Files), we need to include this file to the projectA.
I guess you mean you want to use “..\XXX\XXX\Release\projectB.dll.config” path for Release build and use ““..\XXX\XXX\Debug\projectB.dll.config” path for Debug build without using $(Configuration) right?
Generally, MSBuild uses $(configuration) to switch the configuration mode, if it is not available for you, to my knowledge, from MSBuild side, it is hard or not possible to switch/match the configuration mode.

MSBUILD Dynamically Create Config XML Dotfuscator

I am trying to obfuscate bunch of files in a directory and every build there are more and more files being generated. I would like to know if there is a way I can dynamically create the Dotfuscator configuration xml file using a MSBUILD task that will generate the xml file every time there is a new file added to the directory?
This might be a good time to use the Directory input. Rather than representing a single assembly (.exe or .dll), this type of Dotfuscator input captures all the assemblies in a directory. When the contents of the directory change, Dotfuscator's build will automatically pick up any new assemblies.
To make a Dotfuscator config file with a Directory input, open the GUI and add an input as you normally would (directions for Community Edition's GUI and for Professional Edition's standalone GUI), but instead of selecting a file from the Browse... dialog, just navigate to the directory and click "Open" while the "File name" is still listed as "Folder Select". Then, save your configuration.
From now on, whenever you run Dotfuscator (whether from the standalone GUI, the command line, the Visual Studio integration, or the MSBuild task), all assemblies in the directory will be processed as input.
Note: If you look at the config file itself, you might be surprised that it will still list individual assemblies:
<input>
<loadpaths />
<asmlist>
<package refid="19e1b0c5-7221-476f-af4b-bafef68edc95">
<file dir="C:\code\BasicTestApp\BasicTestApp\bin" name="Debug" />
<asmlist>
<inputassembly refid="a6da5d8d-c181-4103-840d-d8cc7c85937a">
<option>honoroas</option>
<option>stripoa</option>
<option>transformxaml</option>
<file dir="" name="BasicTestApp.exe" />
</inputassembly>
<inputassembly refid="df84dad0-fbe8-49ab-b8c8-9fb59e706785">
<option>honoroas</option>
<option>stripoa</option>
<option>library</option>
<option>transformxaml</option>
<file dir="" name="ClassLibrary.dll" />
</inputassembly>
</asmlist>
</package>
</asmlist>
</input>
Despite this layout, Dotfuscator will process all assemblies in the C:\code\BasicTestApp\BasicTestApp\bin\Debug directory when it runs a build based off this config file, not just those two listed.
The assembly elements in the config are just there so that you can still make rules against individual assemblies in the GUI (e.g., to make one assembly be in Library Mode).
The list represents the state of the directory when the GUI last modified the config.
Disclaimer: I work for the Dotfuscator team, and am answering this question as part of my job.
Additional note due to clarification in the comments: the directory package has a feature where you can exclude certain assemblies from obfuscation. These assemblies will be treated as a Package Artifact and just copied from input-to-output without modification. Any obfuscated assemblies that refer to these excluded assemblies will still be processed correctly.
To do this in the GUI, right-click on the assembly within the package, and select "Exclude assembly from package". Or, if you'd prefer to edit the config file, add the following <option> tag as a child of each relevant <inputassembly> tag:
<option>artifact</option>
The latest Dotfuscator version 4.41.1 has the latest flag
true
This will generate the Dotfuscator config file if the file is missing. Also you can add this to the csproj as documented in the latest getting started guide https://www.preemptive.com/dotfuscator/pro/userguide/en/getting_started_protect.html

Building with a linked file in WIX

I’ve a project targeting wix 3.7, using VS2013 with a VSO repository. When I add files to a project using “Add As Link”, the build fails with “cannot find the file”. E.g. in the wxs file, I have:
<Icon Id="ArpIcon" SourceFile="Images\favicon.ico"/>
The source file is in a folder outside of the project, and is already checked into VSO. When I build, the error in the Output includes:
… error LGHT0103: The system cannot find the file
'Images\favicon.ico'.
If the file is included directly (i.e. not as a link), then no problem.
Wix Tips & Tricks seems to suggest wix understands linked files. Any ideas on what am I missing?
I've just figured out that if I also change the SourceFile attribute to the real file location rather than where the link appears in the project structure, then it will build. So, with the wixproj line reading as
<Content Include="..\..\_Cobranded Common\Images\favicon.ico">
<Link>Images\favicon.ico</Link>
</Content>
and matching the wxs line to it as
<Icon Id="ArpIcon" SourceFile="..\..\_Cobranded Common\Images\favicon.ico"/>
it now builds.
Would be interested to hear if there's a simpler or more intuitive solution.

Nuget package to include other folders

I am deploying my packages using teamcity and octopus. I am creating packages using teamcity and then using Octopus to deploy to different environments. I have a Resources folder which needs to be copied as a separate step in teamcity. Now I want that folder to be included in the package so I can then deploy that package to remote servers on other domains. I have defined the following file to include resources folder into the content folder of main project. but what's happening is It just create a folder in the destination but don't copy other files with in the project. Please guide as All I want is to include the resources folder with in the package along with my publish website files. I just want the resources folder to be part of package. Please guide
<?xml version="1.0" ?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Services</id>
<version>1.0.0.0</version>
<authors></authors>
<owners></owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Services.nuspec build package</description>
<releaseNotes />
</metadata>
<files>
<file src="..\Resources\**\*.*" target="Content\Resources" />
</files>
</package>
Package contents after creating a package using the above code:-
. _rels
. package
. content\resources
. [content_type
. Services.nuspec
If you're using OctoPack, this behaviour is expected. To quote the documentation on GitHub:
If the <files> section exists, OctoPack won't attempt to automatically add any extra files to your package, so you'll need to be explicit about which files you want to include.
If you go this route, you'll need to specify all the other files you want included within the <files> section of the nuspec.
If you're not using OctoPack, a similar rule applies. See documentation on nuget.org
If you follow the conventions described in Creating a Package, you do not have to explicitly specify a list of files in the .nuspec file. Note that if you specify any files, the conventions are ignored and only the files listed in the .nuspec file are included in the package.
Update
One hybrid method I've seen used is to use the MSBuild Publish target to build & publish the website to a local folder, (to filter out all the compile time files like .cs source), drop in the additional files, and then simply include a <file src="**/*.*" /> to pack everything under the root publish folder. Requires a bit of customisation with root paths / nuget.exe, but it may make the process it a bit neater and slightly less maintenance.
Useful information here that may help you get started.

MSBuild target _CopyWebApplication does not copy all necessary files to the bin folder

Elsewhere on the Web, you can find recommendations on using something like this to simulate the Publish feature in the VS 2005-2008 IDE from a command-line (I hope I did not goof up the syntax!):
msbuild /t:ResolveReferences;_CopyWebApplication /p:BuildingProject=true;OutDir=C:\inetpub\wwwroot\ blah.csproj
Now, it looks like the .dll's copy fine. However, there are certain configuration files and template files that are copied to the bin folder which are needed for the app to work. For example, an NHibernate configuration file shows up in blah.csproj as:
<None Include="blah.cfg.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
While using Publish from within the IDE copies this file as it should, the aforementioned _CopyWebApplication target does not. I need this file to be copied in the build script. Is this desired behavior for _CopyWebApplication? Any recommendations on how to fix this?
EDIT 4/21/2010:
Let me clarify that we are limited (for now) to VS 2005 and VS 2008 projects, and that our build scripts are written for MSBuild 3.x. We are not yet ready to move to VS 2010.
Let me also specify that we are looking for a solution available from within a command line so that we can automate a Publish-like command along with custom build options, and possibly automate deployments down the road.
This is just a workaround.
In the build script for publishing Web sites, after running MSBuild on the Web project itself to publish it (Targets="ResolveReferences;_CopyWebApplication"), I added a copy operation:
<Copy SourceFiles="#(ProjectBinFiles)" DestinationFolder="$(StageBin)\%(ProjectBinFiles.RecursiveDir)" />
where ProjectBinFiles is an Item representing the files in the bin directory in the source directory, and StageBin is a Property representing the bin folder in the published site's directory. So far, it seems to work.
I was having a similar issue as well. I think the answer is using MSDeploy. Investigating it now, but may provide functionality required...
I had this same issue in VS 2012 and eventually fixed it by doing the following to any files which needed to be copied:
Set the Copy to Output file property to Copy if newer
Set the Build Action file property to Content (or Compile if the file needs to be compiled)