In order to support 2 major versions of a CRM SDK I have to have 2 projects that have the same code but different libraries.
The only thing they change in versions are just the imported Libraries, and this not only goes for the default WebProject but all Class Projects that I'm using.
How can I easily have the same code and can test/build for different versions?
For an example:
I have in my Solution:
Class Library: `Authentication.7`
Class Library: `Authentication.6`
Class Library: `Shared.WebControls`
Class Library: `Shared.Utilites`
Web Project: `MyWebApp`
A part of Authentication.6 that really has different code from Authentication.7 library as authentication are very different between these major versions, all other projects just have referenced all needed DLL's from the CRM SDK.
Is there a way to build / test that would load the correct references so I can still use a base code?
What do you guys do in this situations? I'm having a pain to hold into 2 base codes :-/
As long as the base code resides in assemblies with the same names, but with different versions, you could try setting runtime assemblyBindings.
So lets say your assembly is compiled against an earlier version of two base dlls, but you want your same assembly to work with the newer version of the base dlls, add the following to your app|web.config file
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="SoCore"
publicKeyToken="bdda2d694ae22a86"
culture="en-us" />
<bindingRedirect oldVersion="7.0.3000.0-7.0.4002.0" newVersion="7.0.4003.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="SoDatabase"
publicKeyToken="bdda2d694ae22a86"
culture="en-us" />
<bindingRedirect oldVersion="7.0.3000.0-7.0.4002.0" newVersion="7.0.4003.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Drop in the new assemblies and your assembly - compiled against the older base assemblies, and all should still work - unless the newer base assemblies contains breaking changes in the api you depended on.
One approach would be to have 2 projects for each "identical" library, but use the same set of source files. You can do this by creating a 2nd project (e.g. Shared.WebControls6 and Shared.WebControls7) and using the Add As Link option when adding existing files to the new project - the existing project already has all the files. Note that this has the drawback that any changes to the project files (e.g. adding a new class) needs to happen to both projects.
Another option might be to get fancy within the project file itself. Possibly something like (note: not tested):
<ItemGroup>
<Reference Include="Authentication.7" Condition=" '$(foo)' == '7' " />
<Reference Include="Authentication.6" Condition=" '$(foo)' == '6' " />
</ItemGroup>
<!-- or -->
<ItemGroup>
<Choose>
<When Condition="'$(foo)'=='7'">
<Reference Include="Authentication.7" Condition=" '$(foo)' == '7' " />
</When>
<Otherwise>
<Reference Include="Authentication.6" Condition=" '$(foo)' == '6' " />
</Otherwise>
</Choose>
</ItemGroup>
To build, you'd have to set the value of foo to the version you wish to build against (e.g. msbuild myproj.csproj /p:foo=7).
Related
I want to create my own custom package for System.Data.SQLite. I have the all the dll's I need but I'm unsure how to structure it and create the nuspec for it.
Current folder structure of the dll's is this, whereabouts would I put the different interop dlls to have them copied correctly to the output and what do I need to add to the nuspec?
lib/net452
-> System.Data.SQLite.dll , System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll
Custom.SQLite.nuspec
Still have the default nuspec something like this atm
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Custom.SQLite.Name</id>
<version>1.0.0.0</version>
<authors>name</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Desc</description>
<copyright>Copyright 2021</copyright>
</metadata>
</package>
SQLite.Interop.dll does not act as a lib assembly dll. That is not its role. And it should be a content file rather than a assembly dll. So it should not be packed as lib.
To create such custom nuget package, you should first pack System.Data.SQLite.dll, System.Data.SQLite.Linq.dll, System.Data.SQLite.EF6.dll as lib. See this document.
and then pack SQLite.Interop.dll as content.
Also, to make the content file be copied into the output folder of the main project when you install the nuget package, you have to use a <packages_id>.props or targets file to realize it.
1) create a file called <packages_id>.props into your class library project. And it should be the same name as your nuget package. In your side, it should be named as Custom.SQLite.Name.props. Otherwise, it will not work.
And then add these into the file:
<Project>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)..\content\x86\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)..\content\x64\SQLite.Interop.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
2) use this nuspec file:
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Custom.SQLite.Name</id>
<version>1.0.0.0</version>
<authors>name</authors>
<owners>owner</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Desc</description>
<copyright>Copyright 2021</copyright>
</metadata>
<files>
<file src="System.Data.SQLite.dll" target="lib\net452" />
<file src="System.Data.SQLite.EF6.dll" target="lib\net452" />
<file src="System.Data.SQLite.Linq.dll" target="lib\net452" />
<file src="xxx\x86\SQLite.Interop.dll" target="content\x86" />
<file src="xxx\x64\SQLite.Interop.dll" target="content\x64" />
<file src="Custom.SQLite.Name.props" target="build" />
</files>
</package>
3) rebuild your lib project and then use nuget pack to pack the new version.
Before you use this new version, please uninstall the old one and delete all cache files under C:\Users\xxx\.nuget\packages\Custom.SQLite.Name and <solution_folder>\packages\Custom.SQLite.Name.1.0.0. Then, reinstall the new version.
When I try to build my Asp .Net Core (1.1.2) App, I'm receiving the following warning:
Found conflicts between different versions of "System.Net.Http" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
This then turns into a runtime error so I'm trying to fix this warning...
I turned on detailed logging in Visual Studio and I see this in the build output window:
There was a conflict between "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll].
C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll
Project file item includes which caused reference "C:\Users\mdepouw\.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll".
System.Net.Http
References which depend on "System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\System.Net.Http.dll].
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll
Project file item includes which caused reference "C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll".
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.applicationinsights.aspnetcore\2.1.1\lib\net451\Microsoft.ApplicationInsights.AspNetCore.dll
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
Project file item includes which caused reference "C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll".
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Persistence.MarkLogic.dll
Project file item includes which caused reference "C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Persistence.MarkLogic.dll".
C:\Users\mdepouw\Source\Repos\MyProject\MyProject.Services.Common\bin\x64\Debug\MyProject.Services.Common.dll
... more dlls that reference 4.1.1.2
Dependencies
I don't understand the part that tells me which "References" depend upon System.Net.Http, Version=4.1.1.0. I'm reading it as it depends upon itself. What am I misunderstanding?
I'm not referencing System.Net.Http directly either via Assembly references nor as a Nuget reference.
Also, the file in "C:\Users\mdepouw.nuget\packages\system.net.http\4.3.1\ref\net46\System.Net.Http.dll" is version 4.1.1.0.
Update: The original fix worked for my WebApi but didn't work for Viewing MVC Pages. I started to receive another runtime exception: Can not find assembly file Microsoft.CSharp.dll.
I changed <DependsOnNETStandard>true</DependsOnNETStandard> to <DependsOnNETStandard>netstandard1.6</DependsOnNETStandard> and that resolved the issue.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<AssemblyName>MyProject</AssemblyName>
<Platforms>AnyCPU;x64</Platforms>
<DependsOnNETStandard>netstandard1.6</DependsOnNETStandard>
</PropertyGroup>
...
</Project>
Original Answer:
I added <DependsOnNETStandard>true</DependsOnNETStandard> per this GitHub Issue and my build warning went away and so did my runtime error.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<IsServiceFabricServiceProject>True</IsServiceFabricServiceProject>
<AssemblyName>MyProject</AssemblyName>
<Platforms>AnyCPU;x64</Platforms>
<DependsOnNETStandard>true</DependsOnNETStandard>
</PropertyGroup>
...
</Project>
I don't understand the part that tells me which "References" depend upon System.Net.Http, Version=4.1.1.0. I'm reading it as it depends upon itself. What am I misunderstanding?
That because one of dependencies for Microsoft.AspNetCore drags in NETStandard.Library 1.6 which adds tons of System.* dependencies:
There was a conflict between “System.Net.Http”
This is a known issue about .NET core:
System.Net.Http package 4.3.2 - redirect to 4.2.0.0, assembly loading failure
This issue will be fixed in the next version 2.1.0.
The current workaround provided by Tornhoof:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
</assemblyBinding>
It uses the dll from the build extensions directory and not the one from Nuget.
I have a few question regarding Microsoft.AspNet.WebApi NuGet package source code:
Where is located repository with Microsoft.AspNet.WebApi Nuget package source code.
What commit id corresponds to version 5.2.3 of the NuGet package.
What *.nuspec file was used to create Microsoft.AspNet.WebApi package?
Thanks!
I was looking for the exact same thing and I finally found it. This page lists out the versions and where they correspond in the source. It is v.3.2.3 that maps to 5.2.3.
Repository Tags and Version Numbers
BY Scott Hanselman: http://www.hanselman.com/blog/CreatingANuGetPackageIn7EasyStepsPlusUsingNuGetToIntegrateASPNETMVC3IntoExistingWebFormsApplications.aspx
POSTED TO AVOID LINK ONLY ANSWER!
HOW I MADE MY OWN NUGET PACKAGE AND YOU SHOULD TOO BY Scott Hanselman:
Step 0 - Go get the NuGet.exe command line here. Put it in the Path or somewhere.
Step 1 - Make a folder for your new package, go there via the commmand line and run "nuget spec"
C:\Users\Scott\Desktop\AddMvc3ToWebForms>nuget spec
Created 'Package.nuspec' successfully.
C:\Users\Scott\Desktop\AddMvc3ToWebForms>dir Package.nuspec
Directory of C:\Users\Scott\Desktop\AddMvc3ToWebForms
02/15/2011 02:23 AM 813 Package.nuspec
1 File(s) 813 bytes
Now, I changed this file's name and edited it thusly.
<?xml version="1.0"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>AddMvc3ToWebForms</id>
<version>0.4</version>
<authors>Scott Hanselman</authors>
<owners>Scott Hanselman</owners>
<iconUrl>http://www.hanselman.com/images/nugeticon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A totally unsupported way to quickly add ASP.NET MVC 3 support to your WebForms Application. Works on my machine.</description>
<tags>MVC MVC3 ASP.NET WebForms</tags>
</metadata>
</package>
Step 2 - Add stuff to your Content Folder
Since I want my NuGet package to add stuff to folders in my target Web Application, I put whatever I want in a folder called Content. Anything in that will show up in the root of my target project. This can be CSS, JS, CS or VB files, whatever. These files will all get dropped onto the project your package is applied to.
In my project I took the folders from an MVC application and put them in my NuGet folder structure. So, Content, Controllers, Models, Scripts, Views. Copied them right over from an existing blank ASP.NET MVC project.
My NuGet directory where I'm building the package
Step 3 - Decide what needs to be Pre-Processed
However, when my HomeController shows up in your project, Dear Reader, I don't want it to be in the namespace ScottMvcApplication! You want it in MvcApplication54 or whatever your project name is. I need pre-process the source a little to use your project's context, names, namespaces, etc.
For the files I want pre-processed automatically by NuGet, I add a .pp extension. In my example, HomeController.cs.pp.
Preprocessor files with a .pp extension
Then I add a few tokens I want replaced at install-time for that package. For example $rootnamespace$ or $assemblyname$. You can use any Visual Studio Project Property per the NuGet docs.
namespace $rootnamespace$.Controllers
{
public class HomeController : Controller
{
//snip
}
}
Step 4 - Decide what XML elements need to be merged (usually into web.config)
The next preprocessing that is common is adding elements to web.config. This is a nice little feature of NuGet because you just need to make a web.config.transform with the new elements and it will automatically and non-destructively add (and remove) them as needed. Here's my web.config.transform, for reference. Note this is not a full web.config. This is the one I added to my package in the control folder.
<configuration>
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Step 5 - Add any PowerShell script you might need, especially for adding references
Almost done. Most package won't need much PowerShell, but some do. You can have an install.ps1 and an uninstall.ps1 and do lots of things. These go in a folder called Tools that's next to Content (not inside.)
Here's my install.ps1.
NOTE: Currently today there's no way to STOP the installation of a package while it's happening, so if you try to install mine on NuGet 1.0 I'll just warn you and ask you to uninstall. In the future there will likely be a pre-install or a dependency check. Hence the version check there.
param($installPath, $toolsPath, $package, $project)
if ($host.Version.Major -eq 1 -and $host.Version.Minor -lt 1)
{
"NOTICE: This package only works with NuGet 1.1 or above. Please update your NuGet install at http://nuget.codeplex.com. Sorry, but you're now in a weird state. Please 'uninstall-package AddMvc3ToWebForms' now."
}
else
{
$project.Object.References.Add("Microsoft.CSharp");
$project.Object.References.Add("System.Web.Mvc");
$project.Object.References.Add("Microsoft.Web.Infrastructure");
$project.Object.References.Add("System.Web.WebPages");
$project.Object.References.Add("System.Web.Razor");
$project.Object.References.Add("System.ComponentModel.DataAnnotations");
}
Note that in (the future) NuGet 1.2 I won't need this code, I'll just add the references in my NuSpec file directly.
Step 6 - Pack it up
Go back to the command line and run nuget pack
C:\Users\Scott\Desktop\AddMvc3ToWebForms>nuget pack
Attempting to build package from 'AddMvc3ToWebForms.nuspec'.
Successfully created package 'C:\Users\Scott\Desktop\AddMvc3ToWebForms\AddMvc3ToWebForms.0.4.nupkg'.
Step 7 - Submit your package
Next, login to the NuGet Gallery (beta) and Contribute Your Package. Just walk through the wizard and upload the nupkg. You can also get an API Key and use the command line tool to do this automatically, perhaps as part of a build process.
Submitting my app to the NuGet Gallery
That's it. If you've got an open source librar
I had a large Silverlight project with an unwieldy web.config, which used transforms against the web.debug.config, web.uat.config, and web.release.config files.
I've not separated out my EntLib configuration into EntLib.config, with matching EntLib.debug.config, EntLib.uat.config and EntLib.release.config files. I've edited the .csproj file and used DependentUpon so that the files are nested under EntLib.config. Now I'm trying to get VS2010 to apply the transforms when I use the Publish... menu option to publish the files straight to the test server.
I've been trying to apply this as shown below but it doesn't seem to work. I can see the transformed EntLib.config file in obj\$(Configuration)\TransformWebConfig\transformed but it isn't deployed. I've also tried using Project > Build Deployment Package which I've then run on another machine. Both leave me with EntLib.config in its original form plus each of the EntLib.($Configuration).config files alongside it. Should it work? Any help anyone can offer would be appreciated.
<PropertyGroup>
<ConfigFileName>EntLib.config</ConfigFileName>
</PropertyGroup>
<PropertyGroup>
<!-- This property is used to handle circular dependency between
TransformWebConfig and our custom target TransformAppConfig -->
<FirstRun Condition="$(FirstRun) == ''">true</FirstRun>
</PropertyGroup>
<!-- This target will be called one time after a call to TransformWebConfig -->
<Target Name="TransformAppConfig" AfterTargets="TransformWebConfig" Condition="$(FirstRun) == 'true'">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="TransformWebConfig" Properties="ProjectConfigFileName=$(ConfigFileName);
Configuration=$(Configuration);
FirstRun=false" />
</Target>
<!-- This target will be called one time before PreAutoParameterizationWebConfigConnectionStrings
to add $(ConfigFileName) to autoparameterization step -->
<Target Name="AddToAutoParameterizationStep" BeforeTargets="PreAutoParameterizationWebConfigConnectionStrings">
<ItemGroup>
<_WebConfigsToAutoParmeterizeCS Include="#(FilesForPackagingFromProject)" Condition="('%(FilesForPackagingFromProject.Filename)%(FilesForPackagingFromProject.Extension)'=='$(ConfigFileName)') And !%(FilesForPackagingFromProject.Exclude)">
<TransformOriginalFile>$(AutoParameterizationWebConfigConnectionStringsLocation)\original\%(DestinationRelativePath)</TransformOriginalFile>
<TransformOutputFile>$(AutoParameterizationWebConfigConnectionStringsLocation)\transformed\%(DestinationRelativePath)</TransformOutputFile>
<TransformScope>$(_PackageTempDir)\%(DestinationRelativePath)</TransformScope>
</_WebConfigsToAutoParmeterizeCS>
<_WebConfigsToAutoParmeterizeCSOuputFiles Include="#(_WebConfigsToAutoParmeterizeCS->'%(TransformOutputFile)')">
</_WebConfigsToAutoParmeterizeCSOuputFiles>
</ItemGroup>
</Target>
I use T4 and TextTransform.exe to create different configs based on build configuration. You can take a look on my snippets for app.config, but the same technique can be applied for web.config.
1) Project structure
ProjectDir
App_Config
Configuration.tt // template for all configs
Debug.App.tt // settings for Debug
Release.App.tt // settings for Release
ProductDeploy.App.tt // settings for deploy
App.config // autogenerated. Ignored in SVN
project.csproj
2) project.csproj modification allows to have up-to-date config for specified Platform/Configuration.
<PropertyGroup>
<T4Template>$(ProjectDir)\App_Config\$(Configuration).App.tt</T4Template>
<T4CommonTemplate>$(ProjectDir)\App_Config\Configuration.tt</T4CommonTemplate>
<T4Config>$(ProjectDir)\App.config</T4Config>
<T4LastConfiguration>$(BaseIntermediateOutputPath)\$(Configuration).t4lastbuild</T4LastConfiguration>
</PropertyGroup>
<Target Name="BeforeBuild" DependsOnTargets="ExecuteT4Templates" />
<Target Name="ExecuteT4Templates" Inputs="$(T4Template);$(T4CommonTemplate);$(T4LastConfiguration)" Outputs="$(T4Config)">
<MakeDir Directories="$(BaseIntermediateOutputPath)" Condition="!Exists('$(BaseIntermediateOutputPath)')" />
<ItemGroup>
<T4ConfigFlags Include="$(BaseIntermediateOutputPath)\*.t4lastbuild" />
</ItemGroup>
<Delete Files="#(T4ConfigFlags)" />
<WriteLinesToFile File="$(T4LastConfiguration)" Lines="T4 Succeeded" Overwrite="true" />
<Exec Command="TextTransform "$(T4Template)" -out "$(T4Config)"" WorkingDirectory="C:\Program Files\Common Files\microsoft shared\TextTemplating\1.2\" />
</Target>
<Target Name="AfterClean">
<ItemGroup>
<T4ConfigFlags Include="$(BaseIntermediateOutputPath)\*.t4lastbuild" />
</ItemGroup>
<Delete Files="#(T4ConfigFlags)" />
</Target>
3) Configuration.tt sample
<## template language="C#"#>
<## output extension= ".config"#>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name = "NameSpace.Properties.Settings.SomeConnectionString"
connectionString = "<#= this.SomeConnectionString #>"
providerName = "System.Data.SqlClient" />
</connectionStrings>
<applicationSettings>
<NameSpace.Properties.Settings>
<setting name="DefAppSetting" serializeAs="String">
<value><#= this.DefAppSetting #></value>
</setting>
</NameSpace.Properties.Settings>
</applicationSettings>
</configuration>
<#+
string SomeConnectionString = "default SomeConnectionString";
string DefAppSetting = "some_value";
#>
4) Debug.App.tt sample
<#
SomeConnectionString = "Data Source=.;Initial Catalog=SomeDB;Integrated Security=True";
DefAppSetting = "debug_some_value";
#>
<## include file="Configuration.tt" #>
I solved this using this article: Xml Document Transforms (XDT) for any XML file in your project by Vishal Joshi and posted the specifics here: How to apply transforms to EntLib.config.
My own solution followed Vishal's option to store his XDT targets file in the project so that it gets stored in source control and is available to everyone, rather than storing it locally on the machine.
I have a .NET library which provides some AJAX controls. The library is build with Visual Studio 2008. The ajax minifier task is used to auto generate minified javascript files.
In a debug build I need the original javascript files for debugging the javascript, but in a release build these have no usage.
What would you recommend? Ignore them in the release and let them blow up the file size? Would there be a penality in loading time? Or would you remove them from the release build? How? I could modify the project file and add a condition attribute. But this does not well integrate in Visual Studio.
EDIT:
To clearify: The primary question is: What are the arguments for including and excluding the non minified files.
UPDATE:
Just found a solution a nice solution for the auto exclusion. Hers a part of my project file:
<ItemGroup>
<EmbeddedJavascript Include="MyJavascript.debug.js" />
<EmbeddedResource Include="MyJavascript.js" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="BeforeBuild">
<ItemGroup Condition=" '$(Configuration)' != 'Release' ">
<EmbeddedResource Include="#(EmbeddedJavascript)" />
</ItemGroup>
<AjaxMin JsSourceFiles="#(EmbeddedJavascript)" JsSourceExtensionPattern="\.debug\.js$" JsTargetExtension=".js" />
</Target>