How to link resource files? - asp.net-mvc

I have a strings.resx file that I've copied to another project. It has an associated strings.designer.cs file. The problem is that once I add them to the VS.NET project, they are separate.
In the older project, strings.designer.cs is a child of strings.resx. If I double click strings.resx, it auto generates a strings1.designer.cs file.
How do I recreate the association?

I could reproduce your issue.
After importing the resource in the new project if you look at the .csproj file you could find an ItemGroup section containing the <Compile Include="string.Designer.cs" /> item, similar to the following
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
....
<Compile Include="string.Designer.cs" />
</ItemGroup>
So to solve your issue do the following
While in VisualStudio unload the project.
Right click on the unloaded project and select "edit {your project name}" from the context menu
Find the ItemGroup section containing your <Compile Include="string.Designer.cs" />
Replace
<Compile Include="string.Designer.cs" />
by
<Compile Include="string.Designer.cs">
<DependentUpon>string.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
Now reload the project ad you should see your files related on the solution explorer

Related

Retain changes to existing files when publishing

I'm stuck in a scenario where my published file is initially correct, but then later is replaced by it's original version. I suspect that the order of events is wrong, coupled with what's in the root directory.
Essentially I have successfully setup my publishing environment where it executes a custom command to create some JavaScript (which gets created outside of my project). Because a file in source control needs to reference this newly created JavaScript, I am simply copying the file (MyControl.ascx) to a temp location (thus it loses the read lock by TFS) and I am having the custom command update the references to the JS. Once this is done, I gather all the files (custom JavaScript, as well as edited MyControl.ascx in it's temp location) and publish.
It publishes everything first, so I see the new JS as well as the updated MyControl.ascx, but a few minutes later it finishes the publish, and Control looks like how it looked in the root directory.
I think what's happening is it's just pushing out what's in the root (which includes MyControl.ascx) on top of my custom Control (which is in another directory).
<PropertyGroup>
<PipelineCollectFilesPhaseDependsOn>
CustomCollectFiles;
$(PipelineCollectFilesPhaseDependsOn);
</PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
Exec Command="MyCommand.bat"
<ItemGroup>
<_BundledJS Include="$(MSBuildThisFileDirectory)..\..\Includes\javascript\*.js" />
<FilesForPackagingFromProject Include="%(_BundledJS.Identity)">
<DestinationRelativePath>Includes\javascript\%(Filename)%(Extension)
</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
<ItemGroup>
<_UpdatedControl Include="$(MSBuildThisFileDirectory)..\..\TempArea\MyControl.ascx" />
<FilesForPackagingFromProject Include="%(_UpdatedControl.Identity)">
<DestinationRelativePath>Controls\%(Filename)%(Extension)
</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
So you can see above i'm taking something that's in ....\TempArea\MyControl.ascx and pushing it out to Controls\%(Filename)%(Extension).
Any ideas how I can tell it to essentially retain my ....\TempArea\MyControl.ascx without then overwriting it with the original MyControl.ascx within the project (....\Controls\MyControl.ascx) ?
Thanks so much!
So I actually ended up figuring it out, and wanted to share:
<ItemGroup>
<_UpdatedControl Include="$(MSBuildThisFileDirectory)..\..\TempArea\MyControl.ascx" />
<FilesForPackagingFromProject Remove="Controls\MyControl.ascx" ></FilesForPackagingFromProject>
<FilesForPackagingFromProject Include="%(_UpdatedControl.Identity)" >
<DestinationRelativePath>Controls\%(RecursiveDir)%(Filename)%(Extension) </DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
So you can see here it actually removes the original control, then adds it back.
I also changed the target as such:
<PropertyGroup>
<OnAfterPipelineCollectFilesPhase>
CustomCollectFiles;
$(OnAfterPipelineCollectFilesPhase);
</OnAfterPipelineCollectFilesPhase>
</PropertyGroup>
Let me know if any questions would be happy to help!

yguard not updating properties file in the jar

I have jar file having some properties files in it like log4j.properties and config.properties. Following is my ant script for yguard. Everything else is working but the properties file updation.
<target name="yguard">
<taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="lib/yguard.jar" />
<yguard>
<inoutpairs resources="none">
<fileset dir="${basedir}">
<include name="MyApp.jar" />
</fileset>
<mapper type="glob" from="MyApp.jar" to="MyAppObs.jar" />
</inoutpairs>
<externalclasses>
<pathelement location="lib/log4j-1.2.17.jar" />
</externalclasses>
<rename conservemanifest="true" mainclass="com.amit.Application" >
<adjust replaceContent="true" >
<include name="**/*.properties" />
</adjust>
</rename>
</yguard>
</target>
config.properties file
com.amit.Application.param1 = something
I found some question in stackoverflow but they didn't help. One place it was mentioned that the file (like jsp, xml, properties) should be in the jar file which I already have. But my yguard obfuscated file just get the files copied as it is.
I tried many combinations with rename & adjust tags but nothing worked for me.
Following post I already visited
Is it possible to manage logs through Obfuscation with yGuard?
How to include obfuscated jar file into a war file
Apparently you want yGuard to obfuscate the name of the field param1, because com.amit.Application is obviously your entry point and yGuard excludes the given main class automatically. So basically you want the outcome to be something like
com.amit.Application.AÖÜF = something
This isn't possible, because yGuard can only adjust class names in property files, as state here: yGuard Manual

WiX Burn bootstrapper cancel dialog localization

I have successfuly created a localized installer and bootstrapper setup using WiX. There is just one problem with the bootstrapper localization. Everything is fine except the values of button captions in a dialog that appears when the installation is being canceled (exit confirmation yes/no). There are no string elements in the bootstrapper theme wxl files that would allow to change these values. In the MSI installer this was possible by setting "WixUIYes", "WixUINo" values.
I have tried to add the following elements to my localized theme file, but without success.
<String Id="WixUIYes" Overridable="yes">some_value1</String>
<String Id="WixUINo" Overridable="yes">some_value2</String>
Is there a way to change the caption values of mentioned buttons? Their values are currently in the system language.
This is my WXS file:
<?xml version='1.0' encoding='windows-1250'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="Test" Version="1.0.0.0" UpgradeCode="MY-GUID">
<WixVariable Id="WixStdbaThemeXml"
Value="Resources\HyperlinkTheme.xml" />
<WixVariable Id="WixStdbaThemeWxl"
Value="Resources\LocalizedHyperlinkTheme.wxl" />
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.HyperlinkLicense" >
<bal:WixStandardBootstrapperApplication LicenseUrl="" SuppressOptionsUI="yes" />
</BootstrapperApplicationRef>
<Chain>
<ExePackage Id="VCRedistExe"
Cache="no"
Compressed="no"
Vital="yes"
SourceFile="vcredist_x86.exe" />
<MsiPackage Id="MyAppMsi"
Cache="no"
Compressed="yes"
Vital="yes"
SourceFile="MyApp.msi"
DisplayInternalUI="yes" />
</Chain>
</Bundle>
</Wix>

Page Inspector Runtime must be registred in root web.config. Warning

In VS 2012 update 1,
I am getting a "Page Inspector Runtime must be registred in root web.config" Warning, when running the page inspector.
Can anyone assist me in what I have to put in the root web.config to fix this . Or some other solution.
Thanks
I realize this is an old question, but since it comes up on a search for the same issue which is still relevant to VS 2019, I thought I'd provide the actual answer:
The error mentioned here is referring to the registration of a file that is in GAC that needs to happen in the machine-level web.config. Not, as the other answers mentioned, in the project's web.config file.
The machine-level web.config file is located (for .net 4+, which I'm assuming is all anyone is using right now) at c:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
And here is what you'll need to add:
<configuration>
..
<system.web>
...
<compilation>
<assemblies>
...
<add assembly="Microsoft.VisualStudio.Web.PageInspector.Loader, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</assemblies>
</compilation>
</system.web>
</configuration>
There's obviously a lot more in your machine-level web.config file - I'm just showing it as above so you see the hierarchy it needs to be in.
Normally this is added by the VS installer. But there are circumstances in which the installer fails to add it or even removes it..
To generate the metadata that is required for some of its features, Page Inspector must instrument the project by adding the following setting to the element in the Web.config file. You can use Page Inspector even if this setting is disabled or it is missing. However, some features like the source selection mapping will not work under these conditions.
Web.config
<add key="VisualStudioDesignTime:Enabled" value="true" />
Add to 'web.config' the key/value suggested by #Vicky_Raj_Sharma above and the "PageInspector:ServerCodeMappingSupport" under , like this:
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<!-- Keys above came with Hot Towel SPA template for VS2012 -->
<!-- Keys below where manually added -->
<add key="VisualStudioDesignTime:Enabled" value="true" />
<add key="PageInspector:ServerCodeMappingSupport" value="Enabled"/>
</appSettings>
When browsing the page (Browse with menu) from within VS it will show the page in your preferred browser.
Still haven´t figured out how to run this directly on IIS8 though...

How to add files to a document library in a site definition in SharePoint 2007?

I'm doing a site definition for SharePoint 2007. When the site is created, a document library called "Folder2" is created also. Now, I need to add some documents to this document library and appear as items in the document library standard views.
My code is:
<Lists>
<List FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" Type="101" Title="Folder2" Url="Folder2">
<Data>
<Rows>
<Row>
<Field Name="Name">MyFile.txt</Field>
<Field Name="Title">MyFile.txt</Field>
<Field Name="FileLeafRef">MyFile.txt</Field>
</Row>
</Rows>
</Data>
</List>
</Lists>
When I see the items of the Document Library there is one element with title "1_". Does anybody know how to add files in a site definition?
The onet.xml I used is the same as blank site.
Thanks!!!
For Document Libraries, instead of Data/Rows/Row, use Modules:
<Lists>
<List FeatureId="00bfea71-e717-4e80-aa17-d0c71b360101" Type="101" Title="Folder2" Url="Folder2" />
</Lists>
<Modules>
<Module Name="Documents" />
</Modules>
Then in Modules at the bottom of onet.xml, you can define your Module as follows:
<Module Name="Documents" Url="Folder2" Path="">
<File Url="MyFile.txt" Name="MyFile.txt" Type="GhostableInLibrary">
<Property Name="Title" Value="MyFile.txt" />
</File>
</Module>

Resources